Code:
SqlConnection con1 = new SqlConnection("Data Source =(local); Initial Catalog=cyberstations; Integrated Security=sspi;");
con1.Open();
string str1 = "select systemname from terminals where systemstatus='0'";
SqlCommand cmd1 = new SqlCommand(str1, con1);
SqlDataAdapter adp1 = new SqlDataAdapter();
DataSet ds1 = new DataSet();
adp1.SelectCommand = cmd1;
adp1.SelectCommand.ExecuteNonQuery();
adp1.Fill(ds1);
combobox1.DataSource = ds1.Tables[0];
combobox1.DisplayMember = "systemname";
combobox1.ValueMember = "systemname";
con1.Close();
here systemstatus used to check the condition. and systemname is the column which must be displayed in combobox.
this code works fine in microsoft visual studio 2005
edit reply report
Comment