along with
{
InitializeComponent();
}
{
cmd.Connection = cn;
loadlist();
}
public Form1()private void Form1_Load(object sender, EventArgs e){
{
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());
}
}
}
{
}
{
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.
}
}
Jignesh TrivediPosted Jan 15, 2013, 11:10 PM
I think you are now assign DisplayMember and ValueMember propery of ListBox.
Try,
DataSet ds = new DataSet();
SqlConnection cn = new SqlConnection("User ID = sa;Password = *****;Data Source= wurthsql;Initial Catalog=P21_12_2");
cn.Open();
SqlDataAdapter adp = new SqlDataAdapter("select * from wurth_item_plating", cn);
adp.Fill(ds);
lbSelect.DataSource = ds
lbSelect.DisplayMember = "Name"
lbSelect.ValueMember = "ID"
hope this will help you.
Akkiraju IvaturiPosted Jan 15, 2013, 11:22 AM
1. If you connection string is wrong, then it should go in to catch block.
2. If connection is good, then check the query text you are executing and see if any data is available.
If connection is good and the query text is fetching data, put a break point and check each loop for the datareader content.