The connection string defines which database server you are using, where It resides, your user name and password and optionally the database name.
//for SQL server
string constr=”server=.; database=dbemployee; uid=sa; pwd=;” ;
//for SQL Express
string constr=”server=.sqlexpress; database=dbemployee; uid=sa; pwd=;” ;
.sqlexpress – server name on the computer
Dbemployee – name of database with which we are dealing
sa – System administrator, user responsible for login in database.
Pwd – password which is blank if not given to the database otherwise we have to mentioned if given at the time of database creation.
SqlConnection cn = new SqlConnection(@”Data Source=.SQLEXPRESS;AttachDbFilename=”+ Application .StartupPath +“\dbdemo.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True”);