我有点卡在这里很长时间了,我只是找不到解决这个问题的方法。
我的本地数据库是 VistaDB。当涉及前 10 个结果时,我的代码有效,但我需要从“Pojam”列中收集所有内容以显示在文本框中,而不仅仅是前 10 个结果。
我的代码在 text_changed 事件处理程序中运行
请帮忙。提前致谢
string pojam = UppercaseFirst(TextBoxPojam.Text.ToLower());
AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection();
VistaDBConnection con = new VistaDBConnection(@"data source='|DataDirectory|Recnik.vdb4';Pooling=true;Open Mode = NonexclusiveReadWrite;");
con.Open();
VistaDBCommand cmnd = con.CreateCommand();
cmnd.CommandType = CommandType.Text;
cmnd.CommandText = "SELECT top(10) Pojam FROM dbo.RecnikFinal";
VistaDBDataReader dReader;
dReader = cmnd.ExecuteReader();
if (dReader.Read())
{
while (dReader.Read())
namesCollection.Add(dReader["Pojam"].ToString());
}
else
{
MessageBox.Show("Data not found");
}
dReader.Close();
TextBoxPojam.AutoCompleteMode = AutoCompleteMode.Suggest;
TextBoxPojam.AutoCompleteSource = AutoCompleteSource.CustomSource;
TextBoxPojam.AutoCompleteCustomSource = namesCollection;