我在删除数据库中的数据时遇到问题。当我点击删除按钮时,弹出错误提示无法强制类型'System.Windows.Forms.TextBox'转换为键入'System.IConvertible'。任何人都可以解决这个问题吗?这是我第一次遇到这个错误。使用MySQL中的存储过程删除数据
以下代码在我的数据库中调用存储过程。
下面的代码我使用
private void button3_Click(object sender, EventArgs e)
{
MySqlParameter[] pms = new MySqlParameter[1];
pms[0] = new MySqlParameter("uProdNo", MySqlDbType.Int32);
pms[0].Value = ProdNo;
MySqlCommand command = new MySqlCommand();
command.Connection = conString;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "pos_delete";
command.Parameters.AddRange(pms);
conString.Open();
if (command.ExecuteNonQuery() == 1)
{
dt.Rows.Clear();
MessageBox.Show("Deleted");
}
else
{
MessageBox.Show("Sorry nothing to be deleted");
}
conString.Close();
}
可能是一个错字:它应该是'ProdNo.Text ',转换为数字 – dlatikay
@dlatikay谢谢 –