Step 1: Create a Class.
Name it MyClass.cs
Step 2: Write Code which is given below:
//Include two namespaces..
using System.Data;
using System.Data.SqlClient;
public Static SqlConnection conn()
{
SqlConnection con = new SqlConnection ("Your Connection
String");
return con;
}
Step 3: Go to Form where you want to access this string..
And Write code as given below:
//You must include above two namespaces..
using System.Data;
using System.Data.SqlClient;
SqlConnection con = MyConnection.conn();
Name it MyClass.cs
Step 2: Write Code which is given below:
//Include two namespaces..
using System.Data;
using System.Data.SqlClient;
public Static SqlConnection conn()
{
SqlConnection con = new SqlConnection ("Your Connection
String");
return con;
}
Step 3: Go to Form where you want to access this string..
And Write code as given below:
//You must include above two namespaces..
using System.Data;
using System.Data.SqlClient;
SqlConnection con = MyConnection.conn();