articles

Home / DeveloperSection / Articles / Connection String

Connection String

Amit Singh8835 02-Sep-2010

Connection string is one of the important part in database connectivity because without database connectivity we cannot connect the database with our project.

 Connection string is a string that specifies information about a data source and the means of connecting to it. It is passed in code to an underlying driver or provider in order to initiate the connection. Whilst commonly used for a database connection, the data source could also be a spreadsheet or text file.

The connection string may include attributes such as the name of the driver, server and database as well as security information such as user name and password

Syntax:

SqlConnection cn=new SqlConnection(“servername”;”database”;”uerid”;”password”);

For example:

 //these lines are for creating a new connection by passing server name,uid,password and name of the database 
SqlConnection con = newSqlConnection("server=abc-pc1\\sqlexpress; database=mind; uid=sa; password=sa ");
//open connection      
con.Open();

Updated 26-Aug-2019

Leave Comment

Comments

Liked By