Thursday, December 30, 2010

C# How to remove blank space in string

A blank space is not equal to “”, null or empty. It is actually a good approach to remove blank spaces from start and end of an input before saving it or doing any further processing on it. System.String class provide three trim methods to remove these spaces.


Trim()

This method removes blank spaces from start and end of a string

string input;

input .Trim();


TrimEnd
()

TrimEnd removes blank spaces from end of a string

string input;

input .TrimEnd();


TrimStart()

Use TrimStart() to remove blank spaces from start of a string

string input;

input .TrimEnd();

Sunday, December 5, 2010

What is identity column ? How to insert value in identity column ?

An Int or Number column of database can be set as Identity column then on inserting new record value for identity column is automatically generated and inserted in cell of column. We can manage what is starting value and what will be added for next value. A column can be set as identity field from column properties, important properties related to identity field are Is Identity, Identity Increment and Identity Seed. Direct SQL can also be used to set a column as identity field.

Create table Member (Id int identity(1001,1),Name nvarchar(50));

Here 1001 is identity seed (start from) and 1 is seed (step by). Identity column's. Normally we cannot insert value in a identity field, for inserting value it can be done by setting identity insert on that table on.

set Identity_Insert tableName on;



An identity field is not primary key or unique key yet it can be set as well. Only one table in session can have Identity_insert on at a time.


Sunday, November 28, 2010

Hi, welcome to my blog

Hi,

It is my first and 'test' post. I was writing in different papers and magazines some years back and after this long break I am back now with my blog. I will be posting and sharing stuff on different topics here from time to time, hope you will find my posts useful. I will highly appreciate your comments on my posts, for contacting me please see my contact details in about me page.

Thanks