我在接下来要从我目前拥有的数据集中填充组合框的事情上遇到了难题。我的数据库被称为“PID2db.mdb”,表被称为“客户”
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();
}
}
任何帮助表示赞赏,谢谢
编辑:添加了新的代码段