In my C# Application, I want to pass a connection string manually from a Form(formCon) to connection.cs. I've tried a lot and googled it, but nothing works fine.
This is the code written in connection.cs:
class connection
{
public SqlConnection con;
public SqlCommand cmd = new SqlCommand();
public connection()
{
string conn = "Data Source=ds;Initial Catalog=initcat;uid=sa;pwd=pass";
con = new SqlConnection(conn);
}
}
I want to replace conn
with the value from frmCon which contains the connection string.