C# “错误”;关键字where";附近的语法不正确;

C# “错误”;关键字where";附近的语法不正确;,c#,database,syntax-error,C#,Database,Syntax Error,我在点击btnguardar时出错,打开MessageBox说“关键字“where”附近的语法不正确” 你们能帮我解决这个问题吗?这是什么版本的SQL?微软SQL?没有where子句。注释的out行更接近正确的语法(尽管您应该使用参数)。您的错误在查询语句上,没有out insert into表,而是使用out into语句设置 private void btnguardar_Click(object sender, EventArgs e) { try

我在点击btnguardar时出错,打开MessageBox说“关键字“where”附近的语法不正确”


你们能帮我解决这个问题吗?

这是什么版本的SQL?微软SQL?没有where子句。注释的out行更接近正确的语法(尽管您应该使用参数)。您的错误在查询语句上,没有out insert into表,而是使用out into语句设置
private void btnguardar_Click(object sender, EventArgs e)
    {
        try
        {
            con.Open();
            string Query = "INSERT Produtos where (id_subcategoria= @id_subcategoria, nome_produto= @nome_produto, quantidade= @quantidade, preco_unitario= @preco_unitario, iva= @iva)";
            SqlCommand createCommand = new SqlCommand(Query, con);
            createCommand.Parameters.AddWithValue("@id_subcategoria", this.label4.Text);
            createCommand.Parameters.AddWithValue("@nome_produto", this.txt_nproduto.Text);
            createCommand.Parameters.AddWithValue("@quantidade", this.txtquantidade.Text);
            createCommand.Parameters.AddWithValue("@preco_unitario", Convert.ToDecimal(this.txtpreco.Text));
            createCommand.Parameters.AddWithValue("@iva", Convert.ToDecimal(this.txtiva.Text));
            createCommand.ExecuteNonQuery();
            MessageBox.Show("Registo adicionado com sucesso!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            con.Close();
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

        //"insert into Produtos (id_subcategoria, nome_produto, quantidade, preco_unitario, iva) values('" + this.label4.Text + "','" + this.txt_nproduto.Text + "','" + this.txtquantidade.Text + "','" + this.txtpreco.Text + "','" + this.txtiva.Text + "') ;"; 
    }
string Query = 
"INSERT INTO Produtos (id_subcategoria, nome_produto, quantidade, preco_unitario, iva) 
VALUES (@id_subcategoria, @nome_produto, @quantidade, @preco_unitario, @iva)";