逻辑中缺少sqlite 3错误或缺少数据库

时间:2013-09-26 12:30:49

标签: c# sqlite

我认为这是一个逻辑错误,因为我可以很好地访问我的本地数据库。我的错误代码如下所示:

SQL logic error or missing database
 SQLiteConnection myConnection = new SQLiteConnection();
        myConnection.ConnectionString = @"Data Source= C:\Users\Lewis Elliott\Desktop\banklist.sqlite3";

        using (myConnection)
        {
            string SQL = "INSERT INTO recipes (Index, name, serves, description, information, method_1, method_2, key, cost, calories, carbs, fat, protein, sodium, sugar, type, is_populated) VALUES";
            SQL += "(@Index, @name, @serves, @description, @information, @method_1, @method_2, @key, @cost, @calories, @carbs, @fat, @protein, @sodium, @sugar, @type, @is_populated)";

            SQLiteCommand cmd = new SQLiteCommand(SQL);
            cmd.Connection = myConnection;

            cmd.Parameters.AddWithValue("@Index", Guid.NewGuid());
            cmd.Parameters.AddWithValue("@name", nameBox.Text);
            cmd.Parameters.AddWithValue("@serves", servesBox.Text);
            cmd.Parameters.AddWithValue("@description", descriptionBox.Text);
            cmd.Parameters.AddWithValue("@information", informationBox.Text);
            cmd.Parameters.AddWithValue("@method_1", method1Box.Text);
            cmd.Parameters.AddWithValue("@method_2", method2Box.Text);
            cmd.Parameters.AddWithValue("@key", keyBox.Text);
            cmd.Parameters.AddWithValue("@cost", costBox.Text);
            cmd.Parameters.AddWithValue("@calories", caloriesBox.Text);
            cmd.Parameters.AddWithValue("@carbs", carbsBox.Text);
            cmd.Parameters.AddWithValue("@fat", fatbox.Text);
            cmd.Parameters.AddWithValue("@protein", proteinBox.Text);
            cmd.Parameters.AddWithValue("@sodium", sodiumBox.Text);
            cmd.Parameters.AddWithValue("@sugar", sugarBox.Text);
            cmd.Parameters.AddWithValue("@type", typeBox.Text);
            cmd.Parameters.AddWithValue("@is_populated", isPopulatedBox.Text);

            myConnection.Open();
            cmd.ExecuteNonQuery();
            myConnection.Close();

任何人都可以在此逻辑中看到任何错误吗?

0 个答案:

没有答案