private void timer1_Tick(object sender, EventArgs e) { try { SqlConnection con = new SqlConnection(@"Server=192.168.1.4;Database=DIGIQUEUE;User Id=digiq;Password=digiq123;"); con.Open(); string sql1 = "Select callpad_status from callpad "; SqlCommand cmd = new SqlCommand(sql1, con); SqlDataReader sqlReader = cmd.ExecuteReader(); while (sqlReader.Read()) { label1.Text = sqlReader.GetValue(0).ToString(); label2.Text = sqlReader.GetValue(1).ToString(); } sqlReader.Close(); } catch (System.Exception ex) { } }
private void timer1_Tick(object sender, EventArgs e) { try { SqlConnection con = new SqlConnection(@"Server=192.168.1.4;Database=DIGIQUEUE;User Id=digiq;Password=digiq123;"); con.Open(); string sql1 = "Select callpad_status from callpad "; SqlCommand cmd = new SqlCommand(sql1, con); SqlDataReader sqlReader = cmd.ExecuteReader(); label1.Text=""; while (sqlReader.Read()) { label1.Text =label1.Text + sqlReader.GetValue(0).ToString(); //you are selecting only one column in your select query. when you will add one more column in your query then you can use label2 same as label1 label2.Text = sqlReader.GetValue(1).ToString(); } sqlReader.Close(); } catch (System.Exception ex) { } }
Select columnname1 , columnname2 from tablename
while(sqlReader.Read()) { label1.Items.Add(sqlReader["callpad_status"].ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)