小编vtn*_*vtn的帖子

C#编辑SQL中的行

我的代码遇到了一些问题.

这是我的数据库类中的方法

public void editproduct(string a, int b, int c)
{
    conn.Open();
    SqlCommand command = new SqlCommand("UPDATE Productdescription SET pdescription = '" + a + "',Price = " + b + " WHERE pid = " + c + ")", conn);
    command.ExecuteNonQuery();
    conn.Close();
}
Run Code Online (Sandbox Code Playgroud)

我尝试用我的按钮在这里执行它.

private void button1_Click(object sender, EventArgs e)
{
    Database db = new Database();
    db.editproduct(textBox1.Text, Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text));
}
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误::

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box. …
Run Code Online (Sandbox Code Playgroud)

.net c# sql sql-server ado.net

1
推荐指数
1
解决办法
219
查看次数

标签 统计

.net ×1

ado.net ×1

c# ×1

sql ×1

sql-server ×1