我在刪除數據庫中的數據時遇到問題。當我點擊刪除按鈕時,彈出錯誤提示無法強制類型'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謝謝 –