Sunday, December 18, 2011

Creating SQL Connection



Showing how to create a sql connection by code...(Basic). Type this code to create a sql connection using ADO.Net
//con is the object of SqlConnectoin_
 
 SqlConnectoin con= new SqlConnetoin();
 con.ConnectionString = "Data Source =Sqlservername ; Initial Catalog = table name; Integrated Security = True";
 con.Open();
 //Here Sqlserver name = your computer name
 
 (You can see your computer name by :
 right click on MyComputer --> Properties -->Computer Name (tab) --> Change (BUtton)
 
 //If you are connecting sql with user id and
 
 password than remove Integrated security and type :
 SqlConnectoin con= new SqlConnetoin();
 con.ConnectionString = "Data Source =Sqlservername ; Initial Catalog = table name; User id = youruserid; password = yourpassrd";
 con.Open();
Read More......