Sunday, July 8, 2012

How to use substring and len function in sql server 2005 or 2008

I am giving one example from that you will understand How to use Substring and Len Funcation.
Suppose I have one table employee with 1000 of Record. and Having one Column Name is stImage.
This column contain link of Image. stImage contain data like http://www.example.com/images/sqlserversubstring.jpg now I want to change only domain name only replace with http://aspdotnet-example.com/images/sqlserversubstring.jpg for that we will do
update employee set stImage= 'http://aspdotnet-example.com'+
SUBSTRING(stImage,len('http://www.example.com'),len(stImage))
from employee

Tuesday, June 19, 2012

How to Set Identity in Sql Server 2005 or 2008 ?

You have Sql Table Which Having for Example 20 Records. And Identity also 20. Now you want insert new Record with Identity 100 then you pass 99 in below function as Parameter and Table Name and Reseed .
DBCC CHECKIDENT (TableName, reseed, 99)

Tuesday, May 1, 2012

DropDownList value set By FindBy ASP.NET Example

In asp.net there are two ways to FindBy DropdownList. 1.FindByValue and 2.FindByText In FindByValue if more then one List Item text is same then it is working Properly also.
ddlDropDownList.Items.FindByValue(strSearchText).Selected = true;
In FindByText ASP.NET In FindByText if more then one List Item text is same then it is not working Properly also.
ddlDropDownList.Items.FindByText(strSearchText).Selected = true;
There is also other way to DropDownList Select Value through Text but this is Best Way. That's why I choose it.