2
Answers

SQL Connection

Brandon Ferguson

Brandon Ferguson

11y
1.2k
1
I set my SQLConnection


SqlConnection cn = new SqlConnection("User ID = sa;Password = *****;Data Source= wurthsql;Initial Catalog=P21_12_2");

along with


{

InitializeComponent();

}


{

cmd.Connection = cn;

loadlist();

}

public Form1()private void Form1_Load(object sender, EventArgs e)


{


private void loadlist()try

{

listBox1.Items.Clear();

listBox2.Items.Clear();

cn.Open();

cmd.CommandText =

dr = cmd.ExecuteReader();


{


{

listBox1.Items.Add(dr[0].ToString());

listBox2.Items.Add(dr[1].ToString());

}

}

}


{


}


"select * from wurth_item_plating";if (dr.HasRows)while (dr.Read())catch (Exception ex)MessageBox.Show("An error occured: " + ex.Message);finally

{

cn.Close();



when i debug the form loads but the data is not processing back to the lists.


Is there somehting wrong with my connection screen. 

}

}



Answers (2)