SqlConnectionStringBuilder
We often use SqlConnection and set Connectionstring directly or Call from
configurationManager(in Asp.net). Do you know about SqlConnectionStringBuilder
Class. It is under namespace System.Data.SqlClient
You can use this class to set Connectionstring values in SqlConnection Class.
Here is the code :-
SqlConnection
myConnection = new
SqlConnection();
SqlConnectionStringBuilder myBuilder =
new
SqlConnectionStringBuilder();
myBuilder.UserID =
"sa";
myBuilder.Password =
"admin@123";
myBuilder.InitialCatalog =
"test";
myBuilder.DataSource =
"RAVI";
myBuilder.ConnectTimeout =
30;
myConnection.ConnectionString
= myBuilder.ConnectionString;