ive hit a brick wall on what to do next to populate a combobox from a data set currently i have. my database is call “PID2db.mdb” and the table is called “Customer”
string strCon = Properties.Settings.Default.PID2dbConnectionString;
OleDbConnection conn = new OleDbConnection(strCon);
try {
conn.Open();
string strSql = "Select forename,surname from customer where [customerID] ='" + txtName.Text + "'";
OleDbDataAdapter adapter = new OleDbDataAdapter(new OleDbCommand(strSql, conn));
DataSet ds = new DataSet();
adapter.Fill(ds);
cboName.DataSource = ds.Tables[0];
cboName.DisplayMember = "forename";
cboName.ValueMember = "surname";
}
finally {
conn.Close();
}
}
any help is appreciated, thanks
edit: added new code segments
Assuming you have a Form with:
Try this :
If worked so please tell me how is the where, left commented at the moment, else there are any errors, you’ll see inside the textbox.