我对命令 INSERT 有疑问。我编译了应用程序并且这可以工作,但是该行没有插入到数据库中(没有抛出任何错误)。该数据库包含在项目中,并具有“始终复制”属性。我正在使用 WPF 和 C# 开发一个项目,但对于连接和查询,我使用 C#。
谢谢!
public SQLiteConnection conexion;
        SQLiteCommand cmd;
        public MainWindow()
        {
            InitializeComponent();
            Conectar();
        }
        public void Conectar ()
        {
            try
            {
                //Connection
                conexion = new SQLiteConnection("Data Source=eldelbar.s3db;Version=3;New=True;Compress=True;");
                conexion.Open();
                //Insert query
                string insercion = "insert into cerveza (nombre,precio) values('amstel', 1.3);";
                cmd = new SQLiteCommand(insercion, conexion);
                int cantidad = cmd.ExecuteNonQuery();
                if (cantidad < 1)
                    MessageBox.Show("No se ha podido insertar");
                cmd.Dispose();
                conexion.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show("Error2!" + e.Message);
            }
        }