I would like to apply my connection string to the whole winform. If I do this in this case - it will apply to the whole win form, but then i cannot use textbox to enter details:
public partial class Form1 : Form
{
SqlConnection myConnection = new SqlConnection("user id=userName;" +
"password=userPass;" +
"server=.;" +
"Trusted_Connection=yes;" +
"database=dbName; " +
"MultipleActiveResultSets=True;" +
"connection timeout=30");
public Form1()
{
InitializeComponent();
}
And if I will use with textbox I will need to enter the connection string to each method.
Is there anyway to get around it?