无法创建表SQLite Windows 8

时间:2012-07-01 00:26:04

标签: c# 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();
   }

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

1 个答案:

答案 0 :(得分:0)

这是一个Windows应用商店应用吗?如果是这样,您需要使用WinRT版本的SQLite,因为文件IO API已更改。

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