这是我从 db 表中选择单行并将文本插入相应文本字段的代码:
try
{
MessageBox.Show("page=" + GlobalVars.id);
Query = "select Id,Description from SaleItemList where Id = '" +
GlobalVars.id + "';";
cmd = new SQLiteCommand(Query, GlobalVars.conn);
dr = cmd.ExecuteReader();
if ((dr != null) && (dr.HasRows))
{
while (dr.Read())
{
txttitle.Text = dr.GetString(1);
}
}
dr.Close();
cmd.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
它导致此错误:
指定的演员表无效`
在这一行:txttitle.Text = dr.GetString(1);
或 txttitle.Text = dr.GetString(2);
我的数据库表是:
CREATE TABLE "SaleItemList"
(
"Id" INTEGER PRIMARY KEY NOT NULL UNIQUE ,
"Description" VARCHAR NOT NULL UNIQUE
)
我究竟做错了什么?