Tuesday, December 30, 2008

Stored Procedure

Syntax to create Stored Procedure.

CREATE PROCEDURE
-- Add the parameters for the stored procedure here
<@Param1, sysname, @p1> = ,
<@Param2, sysname, @p2> =
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
END


Example :
Suppose there is a table StudentMast Having three fields Roll,Name,Address. I want to make an SP(i.e stored procedure) which will take one parameter and finds records which have name = the parameter.


CREATE PROCEDURE Find_Student_By_Name
@Name Varchar(50) ---This is a parameter
AS

BEGIN
Select *
From StudentMast
Where Name=@Name
END

Friday, December 26, 2008

SQL SERVER 2005 KEY WORDS

ABS
ABS
ACOS
ACTION
ADD
AGGREGATE
ALL
ALTER
AND
ANY
AS
ASC
ASCII
ASIN
ATAN
AUTHORIZATION
AVG
BACKUP
BEGIN
BETWEEN
BIGINT
BINARY
BINDING
BIT
BREAK
BROWSE
BULK
BY
CASCADE
CASE
CAST
CATALOG
CEILING
CHAR
CHARACTER
CHECK
CHECKPOINT
CLOSE
CLUSTERED
COALESCE
COLLATE
COLLECTION
COLUMN
COMMIT
COMPUTE
CONSTRAINT
CONTAINS
CONTAINSTABLE
CONTINUE
CONVERT
COS
COUNT
CREATE
CROSS
CURRENT
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURRENT_USER
CURSOR
DATABASE
DATETIME
DAY
DBCC
DEALLOCATE
DECIMAL
DECLARE
DEFAULT
DEGREES
DELETE
DENY
DESC
DISABLE
DISK
DISTINCT
DISTRIBUTED
DOUBLE
DROP
DUMMY
DUMP
ELSE
ENABLE
END
END-EXEC
ERRLVL
ESCAPE
EXCEPT
EXEC
EXECUTE
EXISTS
EXIT
EXP
EXPLICIT
EXTERNAL
FETCH
FILE
FILLFACTOR
FLOAT
FLOOR
FLUSH
FOR
FOREIGN
FREETEXT
FREETEXTTABLE
FROM
FULL
FUNCTION
GET
GO
GOTO
GRANT
GROUP BY
GROUPING
HAVING
HOLDLOCK
IDENTITY
IDENTITYCOL
IF
IN
INCLUDE
INDEX
INNER
INSERT
INT
INTERSECT
INTO
IS
ISOLATION
JOIN
KEY
KILL
LANGUAGE
LEFT
LEVEL
LIKE
LINENO
LOAD
LOG
LOWER
LTRIM
MANUAL
MAX
MESSAGE
MIN
MONEY
MONTH
MOVE
NATIONAL
NCHAR
NO
NOCHECK
NONCLUSTERED
NOT
NULL
NULLIF
NUMERIC
OF
OFF
OFFSETS
ON
OPEN
OPENDATASOURCE
OPENQUERY
OPENROWSET
OPTION
OR
ORDER
OUTER
OUTPUT
OVER
PATH
PERCENT
PI
PLAN
POWER
PRECISION
PRIMARY
PRINT
PROC
PROCEDURE
PROFILE
PUBLIC
RADIANS
RAISERROR
RAND
RANGE
RAW
READ
READTEXT
REAL
RECONFIGURE
REFERENCES
REPLACE
REPLICATE
REPLICATION
RESTORE
RESTRICT
RETURN
RETURNS
REUSE
REVOKE
RIGHT
ROLE
ROLLBACK
ROWCOUNT
ROWGUIDCOL
RTRIM
RULE
SAVE
SCHEMA
SELECT
SERVICE
SESSION_USER
SET
SETUSER
SIN
SIGN
SHUTDOWN
SETUSER
SIZE
SMALLINT
SOME
SORT
SOUNDEX
SPACE
SQRT
STATISTICS
SUBSTRING
SUM
SYSTEM_USER
SYNONYM
TABLE
TAN
TEXTSIZE
THEN
TIME
TIMESTAMP
TINYINT
TO
TOP
TRAN
TRANSACTION
TRIGGER
TRUNCATE
TSEQUAL
TYPE
UNION
UNIQUE
UNNEST
UPDATE
UPDATETEXT
UPPER
USE
USER
VALUE
VALUES
VARBINARY
VARCHAR
VARYING
VIEW
WAITFOR
WHEN
WHERE
WHILE
WITH
WRITETEXT
YEAR

Tuesday, December 23, 2008

How to select an item in DropDownList In Asp.net ?

ddl_Vehicle.ClearSelection();
ddl_Vehicle.Items.FindByText("Bus").Selected = true;

Thursday, December 4, 2008

Reading XML FIle In Asp.Net

//Here I am giving function to read xml file
public DataTable ReadXmlFile()
{
try
{
ReadXmlFs = new FileStream (

HttpContext.Current.Server.MapPath("~/test.xml"), FileMode.Open);
XmlTextReader rdXml = new XmlTextReader(ReadXmlFs);

ds.ReadXml(rdXml);

ReadXmlFs.Close();
return ds.Tables[0];
}
catch (Exception ex)
{
DataTable dTbl = new DataTable();
return dTbl;
}
}

Tuesday, December 2, 2008

Exception / Error Handling In Javascript

< script language = "JavaScript" >
try
{
var I = 10;
var J = 0;
var K = I/J;
}
catch ( e )
{
alert("An exception occurred in the script. Error name: " + e.name
+ ". Error message: " + e.message);
}
< / script >

Sunday, November 30, 2008

Paging in DataGrid

Go to Property Builder - > Paging - > Check Allow Paging and set properties according to your choice.

protected void DataGrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
DataGrid.CurrentPageIndex = e.NewPageIndex;
//Rebind your grid here
DataGrid.DataSource=DataSource;
DataGrid.DataBind();
}

Monday, November 24, 2008

Javascript to open popup window

< script type=" text/javascript " >

var w = screen.availWidth; //For Screen Width
var h = screen.availHeight; //For Screen Height
var Width = (w-100); //
var Height = (h-100);
var left = (w-Width)/2;
var top = (h-Height)/2;

window.open(Path, 'NameOfWindow', 'width='+ Width +', height='+ Height +',top='+ top +',left='+ left +', menubar=no, resizable=no,scrollbars=yes')


< / script >

Wednesday, November 12, 2008

Boxing and UnBoxing

Converting a value type to reference type is called Boxing. Unboxing is an explicit operation.


Example :

class A
{
static void Main()
{
int i = 1;
object o = i; // boxing
int j = (int) o; // unboxing
}
}

Tuesday, November 11, 2008

PUre object oriented language

PUre object oriented language must support these properties.

1. Encapsulation/Information Hiding
2. Inheritance
3. Polymorphism/Dynamic Binding
4. All pre-defined types are Objects
4. All operations performed by sending messages to Objects
5. All user-defined types are Objects

Saturday, November 8, 2008

Javascript on asp.net page

Suppose you want to call some javascript on click of any asp.net button after executing some asp code , you can register javascript and get executed .


string javaScript = " ( script language=' javascript' ) window.close( ) (/script) "; Page.RegisterStartupScript("myScript", javaScript);

This will close the window where this code will be executed.

Thursday, November 6, 2008

Javascript data types

1.Number
2.String
3.Boolean
4.Function
5.Object
6.Null
7.Undefined

Wednesday, November 5, 2008

isNaN

Return true if the argument is not a number

Tuesday, November 4, 2008

Javascript to check if user input has digit in it.

function HasDigit(txt)
{
strLen = txt.length;

for(i=0 ; i < strLen ; i++ )
{
if( (txt.charAt(i)=="0") || (txt.charAt(i)=="1") || (txt.charAt(i)=="2") || (txt.charAt(i)=="3") ||
(txt.charAt(i)=="4") || (txt.charAt(i)=="5") || (txt.charAt(i)=="6") || (txt.charAt(i)=="7") ||
(txt.charAt(i)=="8") || (txt.charAt(i)=="9"))
{
return true;
}
}
return false;

}

Monday, October 27, 2008

To Check if an input contains any afphabetic values

function HasAlpha(Txt)
{
strLen = Txt.length;

for(i=0; i < strLen;i++)
{
if((Txt.charAt(i)<"0") || (Txt.charAt(i)>"9"))
{
return true;
}
}
return false;


}

Saturday, October 25, 2008

How to open sql Connection ?

private string sqlString = "Data Source=Server_Name;Initial Catalog=Database_Name;Integrated Security=SSPI;";

private SqlConnection sqlConn;

if (sqlConn.State != ConnectionState.Closed)
{
sqlConn.Close();
}
sqlConn = new SqlConnection(sqlString);
sqlConn.Open();

/*
Standard Security:

1.
"Data Source=Server_Name;Initial Catalog= Database_Name;UserId=Username;Password=Password;"

2.

"Server=Server_Name;Database=Database_Name;
UserID=Username;Password=Password;Trusted_Connection=False"

Trusted connection:

1. "Data Source=Server_Name;Initial Catalog=Database_Name;Integrated Security=SSPI;"

2."Server=ServerName;Database=Database_Name;
Trusted_Connection=True;"

*/

Monday, October 20, 2008

How to iterate through datagrid items with paging ?

Suppose I have one DataGrid with one item column with CheckBox chk_Select. I want

to check the checked record and want to process it.

for (int cnt = 0; cnt < DataGrid.PageCount; cnt++)
{
DataGrid.CurrentPageIndex = cnt;
DataGrid.DataSource=ds;
DataGrid.DataBind();

for (int i = 0; i < DataGrid.Items.Count; i++)
{
CheckBox chk_Select = (CheckBox)DataGrid.Items[i].FindControl("chk_Select");
if (chk_Select.Checked)
{
//Process the row here
}
}
}

Friday, October 17, 2008

How to inherit from a class in c# ?

public class MyDerived : MyBase
{

}

Wednesday, October 15, 2008

How to get element in child window in javascript ?

***Parent Form Coding Parent.html

(html)
(body)
(input type='text' id='txtName')
(input type='button' id='btnOk' value='Ok'
onClick='window.open("Child.html","Child")')
(/body)
(/html)





***Child Form Coding Child.html
(html)
(head)
(script language='javascript')
function Show()
{
var test = window.opener.document.getElementById("txtName");
alert(test.value);

}

(/script)
(/head)
(body onLoad='Show()')
(/body)
(/html)

Note : Please replace () with <> for every html tags

Monday, October 13, 2008

Export Data From DataGrid To Excel

DataGrid.AllowPaging = false; //cancel paging if there is

Response.ClearContent();
Response.AddHeader("content-disposition", "attachment;filename=" + "FileNameToExportIn");
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
ClearControls(DataGrid);
DataGrid.AllowPaging = false;

DataGrid.DataSource=ds; //Bind Grid Again
DataGrid.DataBind();


//To Show Grid Lines
DataGrid.GridLines = GridLines.Both;

//To Format Header With Color
DataGrid.HeaderStyle.BackColor = System.Drawing.Color.LightGray;

DataGrid.RenderControl(htw);
DataGrid.AllowPaging = true;
DataGrid.DataSource=ds; //Bind Grid Again
DataGrid.DataBind();


Response.Write(sw.ToString());
Response.End();

DataGrid.AllowPaging = true;

Wednesday, October 8, 2008

Error Handling In Sql Server

Error_Number()

Returns the error number of the error that caused the CATCH block of a TRY…CATCH construct to be run in Sql Server. Return type of this function is int.


Error_Line()

Returns the line number at which an error occurred in Sql Server Stored Procedure..

Error_Message()
Returns the message text of the error that occured in Sql Server Stored Procedure.


Example :

BEGIN TRY
SELECT 1/0; --Divide by zero error
END TRY

BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrNumber;
SELECT ERROR_LINE() AS ErrLine;
SELECT ERROR_MESSAGE() AS ErrorMessage;
END CATCH

Tuesday, October 7, 2008

Difference inline and code behind

Inline code written along side the html in a page. Code behind is code written in a seperate file and referenced by the aspx page.

Friday, October 3, 2008

Difference Between Varchar And NVarchar

The difference between the two is that Nvarchar is used to store uNicode data, which is used to store multilingual data in your database tables. Other languages like chinese have an extended set of character codes that needs to be saved and this datatype allows for this extension.

If your database will not be storing multilingual data you should use the varchar datatype instead of nvarchar datatype. Because nvarchar takes twice as much space as varchar.

Wednesday, September 24, 2008

Current Income Tax Slab

Income Tax Slab
Individual Male
Up to Rs. 1,60,000 NIL
Rs.1,60,001 – Rs.5,00,000 10%
Rs.5,00,001 -Rs. 8,00,000 20%
Above Rs. 8,00,000 30%
Individual Female
Up to Rs. 1,90,000 NIL
Rs.1,90,001 – Rs.5,00,000 10%
Rs.5,00,001 -Rs. 8,00,000 20%
Above Rs. 8,00,000 30%
Individual Senior Citizens
Up to Rs. 2,40,000 NIL
Rs.2,40,001 to Rs. 10,00,000 10%
Rs.1,90,001 – Rs.5,00,000 10%
Rs.5,00,001 -Rs. 8,00,000 20%
Above Rs. 8,00,000 30%

Saturday, September 13, 2008

Convert letters to Uppercase

Make on css class definition in your css file if it is or create new and assign CssClass property to the class you make. As shown below.

.ToUpperCase
{
text-transform: uppercase;
}



TextBox1.CssClass=ToUpperCase;

Wednesday, September 10, 2008

Connection Pooling in Asp.Net

Opening a database connection is a resource intensive and time consuming operation.

Connection pooling increases the performance of Web applications by reusing active database

connections instead of creating a new connection with every request. Connection pool manager

maintains a pool of open database connections. When a new connection requests come in, the pool

manager checks if the pool contains any unused connections and returns one if available. If all

connections currently in the pool are busy and the maximum pool size has not been reached, the new

connection is created and added to the pool. When the pool reaches its maximum size all new

connection requests are being queued up until a connection in the pool becomes available or the

connection attempt times out.

Connection pooling behavior is controlled by the connection string parameters. The

following are four parameters that control most of the connection pooling behavior:


Connect Timeout - controls the wait period in seconds when a new connection is requested,

if this timeout expires, an exception will be thrown. Default is 15 seconds.

Max Pool Size - specifies the maximum size of your connection pool. Default is 100. Most

Web sites do not use more than 40 connections under the heaviest load but it depends on how long

your database operations take to complete.

Min Pool Size - initial number of connections that will be added to the pool upon its

creation. Default is zero; however, you may chose to set this to a small number such as 5 if your

application needs consistent response times even after it was idle for hours. In this case the

first user requests won't have to wait for those database connections to establish.

Pooling - controls if your connection pooling on or off. Default is true.

Tuesday, September 9, 2008

Compare case sensitive or case-insensitive string

string str1="Mahmad";
string str2="mahmad"

String.compare(str1,str2,false); //false As third parameter is false which means cas should not be ignored


String.Compare( str1,str2, true ) // true As third parameter is false which means cas should be ignored

Monday, September 8, 2008

Comp off

Compensatory due off: Every employee works for Six/Five days in a week and get one/two day/s off. If an employee is called on such an Off day, he is entitled to enjoy a day off on a working day.

Saturday, September 6, 2008

CMM 5

CMM Capability Maturity Model
CMM 5
CMM 5 describes 5 stages in which an organization manages its work process.

The 5 steps of CMM are :

1. Initial : processes are ad-hoc,chaotic,or actually few processes are defines. We can say that the process is at the very initial stage of software development.

2. Repeatable : It is characteristic of processes at this level that some processes are repeatable.

3. Defined : All processes are defined,documented and integrated into each other for easy communication.

4. Managed : Processes are measured by collecting detailed data on the process and their quality.

5. Optimizing : Continuing process improvement is adopted. That is modification for better performance is carried out over times.

Friday, September 5, 2008

Check dataset is null or not

//To check if the dataset is null or not just count tables in that dataset
if (DS.Tables.Count>0)
{
//Dataset is not null do whatever you want
}

Tuesday, September 2, 2008

ACID rule

1. Atomic - Transaction is one unit of work and does not dependent on previous and next transactions.

2. Consistent - Data is either committed or roll backed, no transaction should be in middle state like some data is committed and some are not.

3. Isolated - No transaction sees the intermediate results of the current transaction i.e one transaction which is in its middle process should not be referenced by another transaction.

4. Durable - The values should persist if the data had been committed even the system crashes right after that transaction.

Monday, September 1, 2008

@@identity

After an INSERT, SELECT INTO, or bulk copy statement is completed, @@IDENTITY contains the last identity value that is generated by the statement. If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL. If multiple rows are inserted, generating multiple identity values, @@IDENTITY returns the last identity value generated

Sunday, August 31, 2008

3 tier Architecture

In 3-tier architecture the system is composed of three layers. The bottom layer is abstracted as data layer. The middle layer is business layer and the top layer is presentation layer.

Flow is like this
Presentation Layer -> Business Layer -> Data Layer -> Data Store

Saturday, August 30, 2008

Marathi

Common Words In Marathi

English Marathi
I Me
You Tumhi / Tu
Please Krupaya
right/Ok Bara / Theek
Yes Ho / Hoy
No Nako
Boy Mulga
Girl Mulgi
Small Lahaan
Big Motha
Fast/Hurry Lavkar
Slow Halhu
Mane Purush/Manoos
Ladies Stree / Mahila
Good/Fine Changla/Mast
Bad Vaiet
Come Yaa
Go Jaa
Here Ikde
There Tikde
We Aamhi
They Tey
Mine Maje
Yours Tumche
Mother Aai
Father Vadil

Numbers
One Ek
Two Doan
Three Teen
Four Chaar
Five Pach
Six Saha
Seven Saat
Eight Aath
Nine Nau
Ten Daha
Eleven Akra
Twelve Bara
Thirteen Tera
Fourteen Chauda
Fifteen Pandhra
Sixteen Solha
Seventeen Satra
Eighteen Athra
Nineteen Ekonees
Twenty Vees
Thirty Tees
Forty Chalis
Fifty Pannas
Sixty Saath
Seventy Sattar
Eighty Ainshi
Ninety Nouvadh
Hundred Shambhar
Thousand Hazaar


Days
Monday Somwar
Tuesday Mangalwar
Wednesday Budhwar
Thursday Guruwar
Friday Shukrawar
Saturday Shaniwar
Sunday Raviwar

Period Of Day
Morning Sakal
Evening Sandhyakaal
Night Ratra


Back Maage
Time Vel
Front Pudhe
Today Aaj
Inside Aat
Tomorrow Udya
Outside Baher
Week Aathawada
Up Var
Month Mahina
Down Khali
Year Varsh
Left Dava
Yesterday Kaal
Right Ujava
Dawn Pahaat
Center Madhye
Mid Night Madhya Ratra
East Purva
North Uttar
West Paschim
South Dakshin
Brother Bhau
Sister Bahin

Where kothe
Is aahe
How kiti
Come Here ikade ya
Return parat
your tumche
name naav
what kai
thanks dhanyavaad
help madati
give dya
price bhav
do kara
reduce kami
call bolva
understand samja
wait/stop thamba
dit basun/basa

Friday, August 29, 2008

Create Trigger To Log DDL Events

CREATE TRIGGER [trgLogDDLEvent] ON DATABASE
FOR DDL_DATABASE_LEVEL_EVENTS
AS
set nocount on
DECLARE @data XML
SET @data = EVENTDATA()
IF @data.value('(/EVENT_INSTANCE/EventType)[1]', 'varchar(100)')
<> 'CREATE_STATISTICS'
INSERT INTO DdlLog..ChangeLog
(
EventType,
ObjectName,
ObjectType,
tsql
)
VALUES (
@data.value('(/EVENT_INSTANCE/EventType)[1]',
'varchar(100)'),
@data.value('(/EVENT_INSTANCE/ObjectName)[1]',
'varchar(100)'),
@data.value('(/EVENT_INSTANCE/ObjectType)[1]',
'varchar(100)'),
@data.value('(/EVENT_INSTANCE/TSQLCommand)[1]',
'varchar(max)')
) ;


ENABLE TRIGGER [trgLogDDLEvent] ON DATABASE

Thursday, August 28, 2008

Color particular row in DataGrid

protected void DataGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemIndex != -1)
{
e.Item.BackColor = System.Drawing.Color.LightYellow;
}
}

Wednesday, August 20, 2008

Trigger

A trigger is a special kind of stored procedure that automatically executes when an event occurs in the database server.
There are two (2) types of triggers in Sql Server 2005 DDL (Data Definition Language) and DML (Data Manipulation Language).
DDL is new in Sql Server 2005.

Syntax to create trigger:

CREATE TRIGGER trigger_name

ON { ALL SERVER | DATABASE }

[ WITH [ ,...n ] ]

{ FOR | AFTER } { event_type | event_group } [ ,...n ]

AS { sql_statement [ ; ] [ ...n ] | EXTERNAL NAME < method specifier > [ ; ] }


When you want to fire the trigger on table level you have to use DML triggers. DML triggers can be on INSERT,UPDATE,DELETE command. While DDL triggers can be used when you want to execute at the time of table,procedure,trigger,function's events like creation , alteration , drop.

Stored Procedure

Syntax to create Stored Procedure.

CREATE PROCEDURE
-- Add the parameters for the stored procedure here
<@Param1, sysname, @p1> = ,
<@Param2, sysname, @p2> =
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
END


Example :
Suppose there is a table StudentMast Having three fields Roll,Name,Address. I want to make an SP(i.e stored procedure) which will take one parameter and finds records which have name = the parameter.


CREATE PROCEDURE Find_Student_By_Name
@Name Varchar(50) ---This is a parameter
AS

BEGIN
Select *
From StudentMast
Where Name=@Name
END

Only Numbers In Text Box In Vb.Net Windows Based Application

Write this code in the KeyPress event of the text box which you want to accept only numeric values.
If Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57 Then
e.Handled = False
ElseIf Asc(e.KeyChar) = 46 Then
e.Handled = False
Else
e.Handled = True
End If

What is fringe benefit tax? What is FBT ?

Fringe Benefit Tax is tax paid by employer after giving any begefit to its employee. Suppose you are working in acompany and the company is giving you the benefit in travelling to your native place from the company location. This benefitwill be under Fringe Benefit Tax and employer have to pay FBT to goverment according to the financial periods rate of FBT.

The purpose for which employer will have to pay FBT.

(a) entertainment;

(b) festival celebrations;

(c) gifts;

(d) use of club facilities;

(e) provision of hospitality of every kind to any person whether by way of food and beverage or in any other manner, excluding food or beverages provided to the employees in the office or factory;

(f) maintenance of guest house;

(g) conference;

(h) employee welfare;

(i) use of health club, sports and similar facilities;

(j) sales promotion, including publicity;

(k) conveyance, tour and travel, including foreign travel expenses;

(l) hotel boarding and lodging;

(m) repair, running and maintenance of motor cars;

(n) repair, running and maintenance of aircraft;

(o) consumption of fuel other than industrial fuel;

(p) use of telephone;

(q) scholarship to the children of the employees.

Income Tax Calculator

Please visit this link for income tax calculation
http://law.incometaxindia.gov.in/TaxmannDit/xtras/taxcalc.aspx

Data Types In SQL Server 2005

Type From To
bigint -9,223,372,036,854,775,808 9,223,372,036,854,775,807
int -2,147,483,648 2,147,483,647
smallint -32,768 32,767
tinyint 0 255
bit 0 1
decimal -10^38 +1 10^38 –1
numeric -10^38 +1 10^38 –1
money -922,337,203,685,477.5808 +922,337,203,685,477.5807
smallmoney -214,748.3648 +214,748.3647

Approximate numerics (Numbers With Decimal Point)
Type From To
float -1.79E + 308 1.79E + 308
real -3.40E + 38 3.40E + 38

datetime and smalldatetime ( SQL Date And Time)
Type From To
datetime Jan 1, 1753 Dec 31, 9999
smalldatetime Jan 1, 1900 Jun 6, 2079

Character Strings
Type Description
char Fixed-length non-Unicode character data with a maximum
length of 8,000 characters.
varchar Variable-length non-Unicode data with a maximum of 8,000
characters.
varchar(max) Variable-length non-Unicode data with a maximum length
of 231 characters (In SQL Server 2005 only).
text Variable-length non-Unicode data with a maximum length
of 2,147,483,647 characters.

Unicode Character Strings (In computing, Unicode is an industry standard allowing computers to consistently represent and manipulate text expressed in most of the world\\\’s writing systems.)

Type Description
nchar Fixed-length Unicode data with a maximum length of 4,000
characters.
nvarchar Variable-length Unicode data with a maximum length of
4,000 characters.
nvarchar(max) Variable-length Unicode data with a maximum length of 230
characters (SQL Server 2005 only).
ntext Variable-length Unicode data with a maximum length of
1,073,741,823 characters.
Binary Strings(Binary Bits i.e 0,1)

Type Description
binary Fixed-length binary data with a maximum length of 8,000
bytes.
varbinary Variable-length binary data with a maximum length of
8,000 bytes.
varbinary(max) Variable-length binary data with a maximum length of 231
bytes (SQL Server 2005 only).
image Variable-length binary data with a maximum length of
2,147,483,647 bytes.

Other Data Types
1) sql_variant: Stores values of various SQL Server-supported data
types, except text, ntext, and timestamp.
2) timestamp: Stores a database-wide unique number that gets updated
every time a row gets updated.
3) uniqueidentifier: Stores a globally unique identifier (GUID).
4) xml: Stores XML data.
5) cursor: A reference to a cursor.
6) table: Stores a result set for later processing.

What is SQL Injection? How to prevent it?

SQL Injection is a technique used to exploit web sites by altering backend SQL statements by manipulating application input. It can happen when any application developer accepts the input of text box in SQL statement as it is.


Here is the example how on can achieve SQL injection.



Suppose a web site has a user authentication form without handling any input. Supplying the input to SQL Query as it is.


A mischievous user knows the user id but don’t know password gives user name and password as below.

User Id = mahmad

Password = abc' OR 'x'='x



So the query by this input will be like given below:

Select *

From UserTable

Where UserId='mahmad'

And Password= 'abs' OR 'x'='x';


This wrong password will work 100% without knowing password and your system is cracked.



How to prevent SQL Injection in this situation?





Solution is simple just replace single quote (') with two single quotes ('').

Escape Sequence (’) In Sql Server 2005,QUOTENAME

Suppose in sql server there is one variable
@String Varchar(max)
Now in this variable you want to store a string like this

Select * From Student_Table Where std_Name Like 'Mah%'
Suppose you are making statement as given below
Set @String='Select * From Student_Table Where std_Name Like 'Mah%''
But this will give you error.

To solve this problem you can use QUOTENAME function of SQL like given below.

Set @String='Select * From Student_Table Where std_Name Like ' + QUOTENAME('Mah%',Char(39))

Where Char(39) is ( ' ) character.

SQL Server 2005 Shortcut Keys

Below I am giving generally used shortcut keys in SQL Server 2005 :

Cancel a query. ALT+BREAK
Connections: Connect. CTRL+O
Connections: Disconnect. CTRL+F4
Connections: Disconnect and close child window. CTRL+F4
Database object information. ALT+F1 (i.e Structure Of Table etc. )
Equivalent to sp_help)
Editing: Clear the active Editor pane. CTRL+SHIFT+DEL
Editing: Comment out code. CTRL+SHIFT+C
Editing: Decrease indent. SHIFT+TAB
Editing: Increase indent. TAB
Editing: Delete through the end of a line in the Editor CTRL+DEL
Editing: Find. CTRL+F
Editing: Go to a line number. CTRL+G
Editing: Make selection lowercase. CTRL+SHIFT+L
Editing: Make selection uppercase. CTRL+SHIFT+U
Editing: Remove comments. CTRL+SHIFT+R
Editing: Replace. CTRL+H
Execute a query. CTRL+E , F5
Help for the selected TSQL statement. SHIFT+F1
Navigation: Switch between query and result panes. F6
Navigation: Switch panes. Shift+F6
New Query window. CTRL+N
Object Browser (To show/hide). F8
Object Search. F4
Parse the query for checking syntax. CTRL+F5
Print. CTRL+P
Results: Display results in grid format. CTRL+D
Results: Display results in text format. CTRL+T
Results: Save results to file. CTRL+SHIFT+F
Results: Show Results pane (toggle). CTRL+R
Save. CTRL+S
Tuning: Index Tuning Wizard. CTRL+I
Change / Select Database. CTRL+U

Accept Only Numbers In Text Box

//This javascript can be used to accept only numbers in any text box in asp.net





//After Adding this script to souce code please add the following statement on pageLoad event to register the java script to text box named txtRs



txtRs.Attributes.Add(”onkeydown”, “JavaScript:return isNumericKeyPressed();”);

What is ERP ?

ERP stands for Enterprise Resource Planning. ERP is a software system which is used to

integrate the data and processes of an organization into one single software system. Usually

ERP systems will have many components including hardware and software, in order to achieve

integration of different departments of big company or organization.
Advantages of ERP Systems

1. Totally integrated system
2. Good bility to share data across various departments in an organization
3. Improved efficiency and productivity levels
4. Better tracking and forecasting with MIS reports.
5. Costs reduction.
6. Better customer satisfaction.
ERP System generally consists modules :
1. Sales.
2. Purchase.
3. Production.
4. Payroll.
5. HR.
6. Inventory.
7. Finance.

What is CTC ?

CTC abbreviates for Cost To Company. Suppose your Gross Salary of a month is
Rs.25000/-. Your annual salary will be 300000(Rs. 3 Lack). So Rs. 300000/ will be your
CTC.

What Is Difference Between CV And Resume ?

Resume is the summary of your Education Qualification,Experience Related information . CV (Curriculum Vitae) is the document with all the details of your Educational Qualification starting from your high school days to graduation,post graduation and Phd. Experience details from starting your career to till date’s information. Also you have to provide information about your current employer and all previous employer with some reference details.
Generally when we are uploading in any career related sites like naukri.com we are uploading resume as it is small enough to quickly go through it.

Search Engines

Most Popular Search Engines
1. Google
2. Whatuseek
3. Wisenut
4. ExactSeek
5. Scrubtheweb
6. Jayde
Other Search Engines
7. AOL Search
8. HotBot
9. Search.com
10.Metacrawler
11.Dogpile
12.Mamma
13.C4
14.Canada.com
15.ixquick
16.Infogrid
17.AllTheWeb.com
18.Query Server
19.800go
20.Debriefing
21.Highway 61
22.com
23.OneSeek
24.MetaSpider
25.Vivisimo
26.PlanetSearch surfwax
27.qbSearch
28.ProFusion
29.Proteus
30.Go 2 Net
31.MegaGo.com
32.WebFile
33.myGO
34.Megacrawler
35.Search Climbers

About Leave

CL Casual Leave
This leave can be taken when there is some emergency or personal

work to be completed.

SL Sick Leave
Obviously when you are sick you are eligible for this type of

leave.
PL Priviledge Leave
This leave is meant for long time leave i.e to go for vacation

etc. When you want PL you have to apply in advance while in CL or SL no

need to prior application.

It depends on the company policy how much leave it provides

generally total 21 leaves are provided in companies i.e 7 SL,7 CL and 7

PL. Many MNCs providing 21 PL and 12 (CL+PL).

MVP Model

This is a model used in software development process. Here logic of different parts of development is devided in three different parts.

1. Model – This is be your business object which has your business logic in it like calling of stored procedures,validations etc.

2. View – This is your User Interface which has controls like TextBox,Label etc.

3. Presenter – This is an object whose only work is to join View and Model.

CSV

CSV stands for Comma Seperated Values. This is a file using for storing data in text format with seperation of comma(,) between two fields. If there is any comma in the field it will be represented by a pair of double-quote characters.
Like:
RollNo-Name-Course-Address
125,Khoja Mahmadhusen,BCA,”Junagam,Pipal Faliya”

Fields with embedded double-quote characters will be delimited by double-quote characters, and the embedded double-quote characters will be represented by a pair of double-quote characters.
Like:
125,Khoja Mahmadhusen,BCA,”Junagam “”123″”,Pipal Faliya”

The first record in a csv file can contain column names in each of the fields.
Like:
RollNo,Name,Course,Address
125,Khoja Mahmadhusen,BCA,”Junagam,Pipal Faliya”

How to create In / Out Parameter for SQL Stored Procedure in asp.net ?

SqlParameter sqlParam = new SqlParameter(paramName, paramType);
sqlParam.Direction = paramDirection;
//which can be ParameterDirection.Input or ParameterDirection.Output

How to run sql query in asp.net ?

private SqlConnection sqlConn=new SqlConnection("ConnectionString");
sqlConn.Open();
SqlCommand sqlCmd = new SqlCommand("Query", sqlConn);
SqlCommand.ExecuteNonQuery()

sqlCmd.Dispose();
sqlConn.Close();

How to copy a row within same table ?

If you want to copy a row in a datatable to the same table you can use ImportRow.
Example :
Suppose a DataTable dtUser has some rows and you want to add another row from the same table.
dtUser.ImportRow(dtUser.Rows[0]);

How To Send DataSet As An XML to SQL Server 2005 Stored Procedure ? Pass DataSet To Stored Procedure

There is some time when we want to send the result of a dataset to send to a stored

procedure without using loop as it is time and resource consuming. Here I am giving an

example how we can send DataSet as XML To Stored Procedure As A Parameter.

Suppose DataSet dsStudent has One table at position 0. Having three columns
GrNo
Name
City

And suppose it has 10 records in front end and you want to send as it is to stored

procedure to make any operation , say to insert into an actual table.

First of all you have to make an input parameter for your stored procedure and send

the dataset as an xml.

dtStudent.GetXml();

This method will send you dataset as a whole to the stored procedure as a parameter.

It will send the parameter’s table as ‘/NewDataSet/Table’. If you have specified a

name to table for dataset instead of Table it will be the name specifi ed by you.

–Declare A Variable To Prepare XML Document
Declare @idoc int

exec sp_xml_preparedocument @idoc OUTPUT,@Param1 –This Statement Will Prepare your

xml document where @Param1 is the parameter passed by you of type XML.

Now let’s insert the data from dataset to the table in SQL Server 2005

Insert Into dbo.Mst_Student
(GrNo,Name,City)

Select GrNo,Name,City
From OpenXML (@idoc,’/NewDataSet/Table’,2)
With (GrNo int,Name Varchar(50),City Varchar(50))

exec sp_xml_removedocument @idoc

This statement will insert all the records from ‘/NewDataSet/Table’ To your actual

table in SQL Server 2005 “Mst_Student”

Please do remember to remove the xml document from memory.

dot net framework 1.1 vs 2.0 , What’s New in the .NET Framework Version 2.0

Please visit below link :
http://msdn.microsoft.com/en-us/t357fb32.aspx

Assembly In Dot Net,What is an assembly in Asp.Net?

An assembly in ASP.NET is a collection of single-file or multiple files. The assembly that has more than one file contains

either a dynamic link library (DLL) or an EXE file. The assembly also contains metadata that is known as assembly manifest.

The assembly manifest contains data about the versioning requirements of the assembly, author name of the assembly, the

security requirements that the assembly requires to run, and the various files that form part of the assembly.



The biggest advantage of using ASP.NET Assemblies is that developers can create applications without interfering with other

applications on the system. When the developer creates an application that requires an assembly that assembly will not affect

other applications. The assembly used for one application is not applied to another application. However one assembly can be

shared with other applications. In this case the assembly has to be placed in the bin directory of the application that uses

it.
Type Of Assembly :

Private Assembly

Shared Assembly



There are many advantages of assembly some of them are as follows:

(1) Increased performance.

(2)Better code management and encapsulation.

(3)Introduces the n-tier concepts and business logic.

What is Common Language Runtime ?

Programming languages on the .NET Framework compile into an intermediate language known as

the Common Intermediate Language (CIL). In Microsoft’s implementation this intermediate

language is not interpreted but rather compiled in a manner known as just-in-time

compilation (JIT) into native code. The combination of these concepts is called the Common

Language Infrastructure (CLI). Microsoft’s implementation of the CLI is known as the Common

Language Runtime (CLR).

Dot Net Framework Version

Version
Version Number
Release Date

1.0
1.0.3705.0
2002-01-05

1.1
1.1.4322.573
2003-04-01

2.0
2.0.50727.42
2005-11-07

3.0
3.0.4506.30
2006-11-06

3.5
3.5.21022.8
2007-11-09

Manifest And Metadeta In Dot Net,Manifest,Metadata

In dot net 2.0 collection of file are called assembly.and in these assembly one file(EXE or .DLL)contains a special metadata called manifest.and these manifest is stored as binary data and contains the detail like versioning requirements for the assembly,the author,security
permissions,and list of files forming the assembly.while the metadata is called data about data.

What is Dot Net Framework ?

.NET Framework in an environment which provides coding,debugging and running programmes written in any .net languages like vb.net,c#.net,j#.net.
The .NET Framework contains three major parts:
* the Common Language Runtime
* the Framework Class Library
* ASP.NET.

How to select an item in DropDownList In Asp.net ?

ddl_Vehicle.ClearSelection();
ddl_Vehicle.Items.FindByText("Bus").Selected = true;

Authentication In Asp.net

Authentication is the process of obtaining identification credentials from a user ( like user name and password ), and validating those credentials against some authority.

There are 4 type of authentication modes which you can set in web.config file.
1.) None
2.) Windows
3.) Forms
4.) Passport

like

ASP.NET State Management

Every time when the web page is posted back to server a new instance of that web page is created. To persist data between different post back events asp.net provides state management.

You can use following features for data persistency.

View state
Control state
Hidden fields
Cookies
Query strings
Application state
Session state
Profile Properties

Where View state, control state, hidden fields, cookies, and query strings stores data at the client side in various formats.While application state, session state, and profile properties store data at the client side.

Please visit http://www.csharphelp.com/archives/archive207.html for more information and example of state management.

Visual Studio 2005 Shortcut Keys

Ctrl-Shift-S Saves all documents and projects
F7 Switches from the design view to the code view in the editor
Shift-F7 Switches from the code view to the design view in the editor
F8 Moves the cursor to the next item, for example in the
TaskList window or Find Results window
Shift-F8 Moves the cursor to the previous item, for example in the
TaskList window or Find Results window
Shift-F12 Finds a reference to the selected item or the item under the
cursor
Ctrl-Shift-G Opens the file whose name is under the cursor or is currently
selected
Ctrl-/ Switches focus to the Find/Command box on the Standard toolbar
Ctrl-Shift-F12 Moves to the next task in the TaskList window
Ctrl-Shift-8 Moves backward in the browse history. Available in the object
browser or Class View window
Shift-Alt-A Displays the Add Existing Item dialog
Ctrl-Shift-A Displays the Add New Item dialog
Ctrl-+ Goes back to the previous location in the navigation history.
Ctrl-Shift-+ Moves forward in the navigation history. This is effectively an undo for the View.NavigateBackward operation
Ctrl-F4 Closes the current MDI child window
Shift-Esc Closes the current tool window
Ctrl-F2 Moves the cursor to the navigation bar at the top of a code
view
Ctrl-Tab Cycles through the MDI child windows one window at a time
Ctrl-F6,Ctrl-Shift-TabMoves to the previous MDI child window
Alt-F6,Ctrl-Shift-F6 Moves to the next tool window
Shift-Alt-F6 Moves to the previously selected window
F6 Moves to the next pane of a split pane view of a single
document
Shift-F6 Moves to the previous pane of a document in split pane view
Ctrl-Shift-F9 Clears all of the breakpoints in the project
Ctrl-Alt-E Displays the Exceptions dialog
F5 If not currently debugging, this runs the startup project or
projects and attaches the debugger. If in break mode, this
allows execution to continue (i.e., it returns to run
mode).
Ctrl-F5 Runs the code without invoking the debugger. For console
applications, this also arranges for the console window to
stay open with a “Press any key to continue” prompt when
the program finishes
F11 Executes code one statement at a time, tracing execution into
function calls
Shift-F11 Executes the remaining lines of a function in which the current
execution point lies
F10 Executes the next line of code but does not step into any
function calls
Shift-F5 Available in break and run modes, this terminates the debugging
session
F9 Sets or removes a breakpoint at the current line
F12 Displays the definition for the selected symbol in code
Ctrl-Alt-A Displays the Command window, which allows you to type commands
that manipulate the IDE
F4 Displays the Properties window, which lists the design-time
properties and events for the currently selected item
Ctrl-Alt-L Displays the Solution Explorer, which lists the projects and
files in the current solution
Ctrl-Alt-K Displays the TaskList window, which displays tasks, comments,
shortcuts, warnings, and error messages
Ctrl-Alt-X Displays the Toolbox, which contains controls and other items
that can be dragged into editor and designer windows

Accounting Effects

Sales
Customer A/C (i.e Debtors) Dr Debited
Sales A/C Cr Credited

Receipt Of Sales
Customer A/C (i.e Debtors) Cr Credited
Cash/Bank A/C Dr Debited

Purchase
Supplier A/C (i.e Creditors) Cr Credited
Purchase A/C Dr Debited

Payment Of Purchase
Supplier A/C (i.e Creditors) Dr Debited
Cash/Bank A/C Cr Credited

TDS Tax Deduction At Source

TDS is deducted by Employer or Buyer of any particulars. The tax is paid to government (i.e in authorized bank) by them on behalf of seeller or employee. As a proof of the deduction employer is giving a copy of Form 16 to employee and buyer is giving a copy of Form 16A to seller so that he can submit it to government body.

Tax Collection At Source (TCS)

TCS is deducted by seller from buyer. For example one buyer buys an item costing Rs.1000/- and seller giving bill of Rs.1100/- as Rs.1000/- item price + Rs.100/- i.e 10% tax on that item.