以下是我从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
)
我做错了什么?