c# - 如何从数据库中获取最近添加的值到自动完成文本框
问题描述
如何将最近添加的值从我的数据库中获取到我的文本框(使用 Autosuggest) 我需要退出应用程序才能查看最近添加到我的文本框的值。我希望有人能在这件事上帮助我。
public void AutoSuggest()
{
List<string> col = new List<string>();
using (var con = SQLConnection.GetConnection())
{
using (var select = new SqlCommand("Select Codeitem from employee_product", con))
{
using (var reader = select.ExecuteReader())
{
while (reader.Read())
{
col.Add(reader["Codeitem"].ToString());
}
txt_code.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
txt_code.AutoCompleteSource = AutoCompleteSource.CustomSource;
txt_code.AutoCompleteCustomSource.Clear();
txt_code.AutoCompleteCustomSource.AddRange(col.ToArray());
AddingProduct();
}
}
}
}
解决方案
推荐阅读
- ubuntu - 如何在 ubuntu 中提取 .tar 文件?
- javascript - 在 React Redux 中使用 Promise
- kubernetes - 使用 helm 指定命名空间
- python - 动态如果布尔值与模块查找
- java - 处理 HicariCP Oracle 连接尝试
- c++ - 静态 constexpr 成员函数在非模板类 C++ 中不可调用
- javascript - 在 mongodb 中按给定值递增所有嵌套值
- java - 无法让 Java 和 C# 通过套接字进行通信
- list - Kotlin - 集合 plus() × plusElement() 的区别
- swift - 执行异步云函数的问题