I was just wondering ... when my (small & new) Project starts up, I have this code right near the start (This is a "Method", is that right ?) :
public KALCForm1()
{
InitializeComponent();
KALCcomboBox1.Items.Clear();
SqlConnection cs = new SqlConnection(@"Data Source=MEDESKTOP;AttachDbFilename=J:\Users\Gary\Documents\Visual Studio 2010\Projects\KALeagueCup\KALeagueCup\KADatabase.mdf;Initial Catalog=myKADB;Integrated Security=True");
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM LEAGUES", cs);
DataTable dt = new DataTable();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
KALCcomboBox1.Items.Add(dt.Rows[i]["LeagueName"]);
}
}
Could this code be kept elsewhere and "Called" from here and from anywhere else if I wanted to re-display the original form, or am I thinking too much like a Mainframe programmer again ?!?!?