Author Archive

Absolute Position for Controls in Asp.net

By default for controls placed in the designer the layout position is as ‘Not Set’ thus we cannot drag the control to a specified location.


We have to change the layout position to absolute position to achieve that.

In Visual Studio we can make the default postion as we need.For that we have to enable the css postioning of controls.

Here is how we can do

1. Go to Layout->Position->Auto-position Options->HTML Designer–>CSS Styling

or

2. Go to Tools->Options->HTML Designer–>CSS Positioning

And check “Change positioning to the following for controls added using Toolbox, paste or drag and drop” and select the postion you perfer.Here we select Absolute Positioning.

Now we can move the controls placed in the designer with absolute positioning.

The Given Procedure is for Visual Studio 2005 which is same for Visual Studio 2008.

Popularity: 12% [?]

Using OVER() with Aggregate Functions in Sql Server 2005

1.you can now add aggregate functions to any SELECT (even without a GROUP BY clause) by specifying an OVER() partition for each function.

2.SUM(..) OVER(..) is most useful for calculating a Total or percentage of a total for each row

3.SUM() function works with any of the other aggregate functions as well, such as MIN() or AVG()

Partition by

Divides the result set into partitions. The window function is applied to each partition separately and computation restarts for each partition.

select
StudentId,
StudentName,
Subject,
Mark,
sum(Mark) OVER (Partition by StudentId) as Total
from
Student

Output
=====
StudentId StudentName Subject Mark Total
======= ========== ===== ==== =====
1 Raja Physics 80 240
1 Raja Maths 90 240
1 Raja Biology 70 240
2 Sam Physics 90 150
2 Sam Maths 60 150

Popularity: 3% [?]

Split Function in Javascript

Split Function: Delimiter :-
The space character ” ” we mentioned will be our delimiter and it is used by the split function as a way of breaking up the string. Every time it sees the delimiter we specified, it will create a new element in an array. The first argument of the split function is the delimiter.

Split() Function:-
The split() function splits text and puts the pieces into an array, with each piece taking up one slot in the array. For example, if you were to split “This is some text”,the split() function would create an array with four slots (zero to 3). The first slot in the array would contain “This”, the second slot would contain “is”, the third “some” and the fourth “text”.

Example:-

 

var stringdata= "1$2$3$4";
var splitdata = stringdata.split("$");
for(i = 0; i < splitdata.length; i++)
{
   document.write("Element " + i + " = " + splitdata [i]);
}


Output
=====
Element 0 = 1
Element 1 = 2
Element 2 = 3
Element 3 = 4

Popularity: 2% [?]

Date Function in Javascript

1.create a date object and store it in a variable

var d= new Date();

 

2.Using the date object,Get the hour,minute,second,month,dayofmonth and year of the Current Date

var hour        = d.getHours();
var minute      = d.getMinutes();
var second      = d.getSeconds();
var month = d.getMonth();
var dayofmonth    = d.getDate();
var year        = d.getYear();

Example:-
Display Next Day of Today

function getNextDate()
{
var date= new Date();
var day = date.getDate();
var month = date.getMonth();
var year = date.getYear();
 
var nextdate= new Date(year, month, day +1);
var nxtDate=nextdate.getMonth()+1+"/"+nextdate.getDate()+"/"+NextDate.getYear();
document.getElementById('DisplaynextDate').value=nxtDate;
//Display Next Date(today+1)
}

Popularity: 1% [?]

StringTokenizer in JAVA

The StringTokenizer class allows an application to break a string into tokens. The tokenization method is much simpler than the one used by the StreamTokenizer class. The StringTokenizer do not distinguish among identifiers, numbers, and quoted strings, nor do they recognize and skip comments.

The set of delimiters (the characters that separate tokens) may be specified either at creation time or on a per-token basis.

An instance of StringTokenizer behaves in one of two ways, depending on whether it was created with the returnDelims having the value True or False :

  • If the flag is Flase , delimiter characters serve to separate tokens. A token is a maximal sequence of consecutive characters that are not delimiters.
  • If the flag is True , delimiter characters are themselves considered to be tokens. A token is thus either one delimiter character, or a maximal sequence of consecutive characters that are not delimiters.

A StringTokenizer object internally maintains a current position within the string to be tokenized. Some operations advance this current position past the characters processed.

A token is returned by taking a substring of the string that was used to create the StringTokenizer object.

Example without Delimiter:-

StringTokenizer st = new StringTokenizer(“Example Of String Tokenizer”);
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}

Output
=====
Example
of
String
Tokenizer

Example with Delimiter:-

StringTokenizer st = new StringTokenizer(“1$2$3$4″,”$”);
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}

Output
=====
1
2
3
4

Popularity: 2% [?]

What is IBATIS?

The iBATIS Data Mapper makes it easier to use a database with Java and .NET applications. iBATIS couples objects with stored procedures or SQL statements using a XML descriptor. Simplicity is the biggest advantage of the iBATIS Data Mapper over object relational mapping tools.

The iBatis framework is a lightweight data mapping framework and persistence API that can be used to quickly leverage a legacy database schema to generate a database persistence layer for your Java application. A set of XML encoded SQL Map files–one for each database table–holds SQL templates that are executed as prepared statements and map the expected results to Java domain classes. From application code, a layer of iBatis Data Access Objects (DAO) acts as the API that executes the SQL Map templates and assigns the results to the corresponding Java domain classes.

To enable communication among DAO layers and Sql Map layers, an XML configuration file describes each DAO interface and implementation class, as well as the location of a second XML configuration file that in turn points to each SQL Map file and contains the database connection information.

Popularity: 1% [?]

Create Database,Table and Procedure in Sql Server – Beginners

Database Creation :

CREATE DATABASE EMPLOYEE

Table Creation :

CREATE TABLE EMPINFO
(
ROWID INT IDENTITY(1,1) NOT NULL,
EMPID INT NOT NULL,
EMPNAME VARCHAR(50) NOT NULL,
EMPDEPT VARCHAR(3) NOT NULL,
EMPSAL INT NOT NULL,
EMPADDRESS VARCHAR(100) NOT NULL,
ACTIVE CHAR(1) NOT NULL DEFAULT ‘T’
)

Procedure Creation :

CREATE PROC EMPINFO_ADD_EDIT
(
@iEMPID INT,
@vEMPNAME VARCHAR(50),
@vEMPDEPT VARCHAR(3),
@iEMPSAL INT ,
@vEMPADDRESS VARCHAR(100),
@cACTIVE CHAR(1)
)
AS
DECLARE @CNT INT;
BEGIN
SET @CNT = 0;
SELECT @CNT = COUNT(*) FROM EMPINFO WHERE EMPID = @iEMPID;
IF(@CNT = 0)
BEGIN

INSERT INTO EMPINFO(EMPID,EMPNAME,EMPDEPT,EMPSAL,EMPADDRESS,ACTIVE)VALUES @iEMPID,@vEMPNAME,@vEMPDEPT,@iEMPSAL,@vEMPADDRESS,@cACTIVE)

END
ELSE
BEGIN

UPDATE EMPINFO SET EMPNAME = @vEMPNAME,EMPDEPT = @vEMPDEPT,EMPSAL = @iEMPSAL, EMPADDRESS = @vEMPADDRESS,ACTIVE = @cACTIVE WHERE EMPID = @iEMPID

END

END

Popularity: 2% [?]

What is Linked List ?

Linked list is one of the fundamental concepts in the data structure. It consists of a set of nodes, each containing a ‘data’ field and one or two references (pointing to adjacent nodes). It is a self referential datatype since it contains reference(s) of the adjacent (next or previous) datum of the same type.

Advantage :
Advantage of linked list compared to conventional array are

  • Insertions and deletions of nodes can be done at anywhere in the list.
  • List size can be increased and decreased in runtime.
  • Order of the linked items can be different from how it is stored in memory or disk, thus allowing the list of items to be traversed in different order.

Types of linked lists exist are Singly linked list, Doubly linked list and Circular linked list.

Popularity: 1% [?]

Swapping a Number

SWAPPING WITHOUT TEMP:

#include <stdio.h>;
 
void main()
{
int a=20,b=30;
a=a+b;
b=a-b;
a=a-b;
printf("a=%d",a);
printf("b=%d",b);
}

SWAPPIG WITH TEMP:

#include <stdio.h>;
void main()
{
int a=20,b=30,temp;
temp=a;
a=b;
b=temp;
printf("a=%d",a);
printf("b=%d",b);
}

Popularity: 1% [?]

Palindrome For String And Numbers

Palindrome Checking Using C:

#include <stdio.h>
#include <conio.h>
#include <string.h>
#define size 26
 
void main()
{
char strsrc[size];
char strtmp[size];
printf("\n Enter String:= ");
gets(strsrc);
strcpy(strtmp,strsrc);
strrev(strtmp);
if(strcmp(strsrc,strtmp)==0)
printf("\n Entered string \"%s\" ispalindrome",strsrc);
else
printf("\n Entered string \"%s\" is not palindrome",strsrc);
getch();
}

Popularity: 1% [?]

Designed by: Business Web Hosting | Thanks to Buy Icons, travel tips and Used Cars