检索链接到人员 ID 的数据库数据并显示在列表框中
本文关键字:显示 列表 数据 数据库 链接 ID 检索 | 更新日期: 2023-09-27 18:30:52
所以我创建了一个链接到MS Acces数据库的应用程序。我有一个登录系统,当登录成功时,他们的个人数据会显示在一些文本框中。其中一个文本框显示其人员 ID(访问数据库的 ID)。
用户可以预约。这将写入数据库中的用户ID - 预约日期 - 治疗。我想检索此信息并将其显示在我的列表框中。但不知道为什么,因为它当然只需要检索链接到登录的用户ID的数据。
我有这样的东西,但我现在被困住了。
connection.Open();
OleDbCommand command = new OleDbCommand();
string afspraken = "select * from Appointments where PersonID = '" + textBox4.Text + "'";
OleDbDataReader reader = command.ExecuteReader();
listBox2.DataSource = reader;
connection.Close();
DataTable dt = new DataTable();
OleDbCommand command = new OleDbCommand();
string afspraken = "select * from Appointments where PersonID = '" + textBox4.Text + "'";
OleDbDataReader reader = command.ExecuteReader();
dt.Load(reader);
foreach (DataRow Dr in dt.Rows)
{
listBox1.Items.Add(Dr["COLUMNNAME"].ToString());
}
con.Close();
试试这个...