how can open two sql connectionString in online project
how can open two sql connectionString in online project
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Najim MullaPosted Nov 19, 2014, 1:16 AM
sir this 3 string connection how can open at a time 2 connection string in web confing page
Manish Kumar ChoudharyPosted Nov 18, 2014, 2:08 AM
Create two Separate connection object and use both connection string separately.
public class Configuration
{
internal static string CS1 = ConfigurationManager.ConnectionStrings["CS1"].ConnectionString;
internal static string CS2 = ConfigurationManager.ConnectionStrings["CS2"].ConnectionString;
}
And now use this connection string as
//Used for First connection string
using (SqlConnection con = new SqlConnection(Configuration. CS1))
{
//code that use First connection string
}
//Used for second connection string
using (SqlConnection con = new SqlConnection(Configuration. CS2))
{
//code that use second connection string
}