我正在尝试将 SQL 语句的结果放入表单上的组合框中。我已经在网上搜寻了答案,但我无法比这更进一步:
using (SqlCeConnection c = new SqlCeConnection(
Properties.Settings.Default.CW2_DBConnectionString))
{
c.Open();
List<Visit> rows = new List<Visit>();
SqlCeCommand cmd = c.CreateCommand();
cmd.CommandText = "SELECT PICKUP_ID FROM PICKUP";
c.Open();
cmd.ExecuteNonQuery();
SqlCeDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
}
cmbPickupID.Items.Add(rows);
}
我不确定在 while 循环中放什么。我确实有类似的东西:
rows.Add(reader["PICKUP_ID"].ToString());
但显然它没有奏效。Visit 类已设置并获取 VisitID。有没有人有任何想法?