为什么我会收到“指定演员表无效”?

时间:2013-10-31 10:22:25

标签: c# asp.net sql wpf sqlite

以下是我从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
)

我做错了什么?

0 个答案:

没有答案