我autocomplete
在 c# 中尝试了文本,并尝试了这段代码,
try
{
textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
AutoCompleteStringCollection col = new AutoCompleteStringCollection();
sqlconn.Open();
string query = "select id from cmp_det where id =" + textBox1.Text;
SqlCommand command = new SqlCommand(query, sqlconn);
SqlDataReader sdr = command.ExecuteReader();
while (sdr.Read())
{
col.Add(sdr["Column_Name"].ToString());
}
sdr.Close();
textBox1.AutoCompleteCustomSource = col;
sqlconn.Close();
}
catch(Exception ex)
{
Console.WriteLine("exception=="+ex);
}
when ) 执行代码出现如下错误:
exception==System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.