我有创建数据库。有一个字段作为IMEI。 我尝试将组合框中的数据建议为下拉列表。但我失败了。请帮我纠正这段代码。我将如何解决此错误。
Private void Autocomplete()
{
OleDbConnection con = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=|DataDirectory|/Neth1.accdb");
con.Open();
string sql = "SELECT IMEI FROM Products";
OleDbCommand comm = new OleDbCommand(sql, con);
OleDbDataReader reader = new OleDbDataReader();
reader = comm.ExecuteReader();
AutoCompleteStringCollection autocomp = new AutoCompleteStringCollection();
while (reader.Read())
{
comboBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
comboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
comboBox1.AutoCompleteCustomSource = autocomp;
}
reader.Close();
con.Close();
}
答案 0 :(得分:0)
OldDbDataReader没有任何公共构造函数,因此您无法像这样构造它。就这样做:
OldDbDataReader reader = comm.ExecuteReader();