繁体   English   中英

无法创建表SQLite Windows 8

[英]Cannot create table SQLite Windows 8

我无法使用SQLite Metro和Windows 8创建表“ IF NOT EXISTS”。如果将“ db”复制到application.local文件夹,则可以添加,编辑删除记录。 它将创建数据库,但不创建表。 我已经使用外部工具检查了我的DDL,它看起来正确。
下面是我的代码:

private void InitData()
    {
        ListBox1.Items.Clear();

        Database db = new Database(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "bppro.db"));

        Statement stm;
        stm = db.PrepareStatement("CREATE TABLE IF NOT EXISTS vitals (_id integer primary key autoincrement, creationdate text,weight text,pulse text,sys text,dia text");
        stm.Execute();
        stm.Dispose();

        string temp = System.DateTime.Now.Ticks.ToString();

        byte[] binaryData = new byte[100];
        stm = db.PrepareStatement("INSERT INTO vitals (creationdate,weight,pulse) VALUES (?,?,?)");
        stm.BindParamText(1, System.DateTime.Now.ToString());
        stm.BindParamInt(2, 35);
        stm.BindParamInt(3, 60);
        stm.Execute();
        stm.Dispose();

        long insertedRowId = db.LastInsertRowId;

        stm = db.PrepareStatement("SELECT * from vitals");
        while (stm.GetNextRow())
        {
            string createdate=stm.GetTextAt(1);
            string weight = stm.GetTextAt(2);
            string pulse = stm.GetTextAt(3);
            ListBox1.Items.Add(createdate.ToString()+"  "+weight.ToString()+"  "+pulse);
        }
        stm.Dispose();
   }

谢谢,任何帮助或指针表示赞赏。

这是Windows Store应用程序吗? 如果是这样,由于文件IO API已更改,您需要使用WinRT版本的SQLite。

在这里查看我对类似问题的回答: https : //stackoverflow.com/a/14469080/68230

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM