How do I load data into combobox from database? I want to display the supportID into the combobox in the form. the code I am using is pasted here. I am calling BindData() in the formload. Ia m getting exception as: Cannot bind to the new display member. Parameter name: newDisplayMember. the code I used is:
public void BindData()
{
SqlConnection con = new SqlConnection(@"server=RSTT2; database = Project ; User Id=sa; Password=PeaTeaCee5#");
con.Open();
string strCmd = "select supportID from Support";
SqlCommand cmd = new SqlCommand(strCmd, con);
SqlDataAdapter da = new SqlDataAdapter(strCmd, con);
DataSet ds = new DataSet();
da.Fill(ds);
cbSupportID.DataSource = ds;
cbSupportID.DisplayMember = "supportID";
cbSupportID.ValueMember = "supportID";
cbSupportID.Enabled = true;
cmd.ExecuteNonQuery();
con.Close();
}