mysql - AddWithValue 不是 MySql.Data.MySqlClient.MySqlParameter VB.net 的成员

标签 mysql vb.net

我的代码会有什么问题?我遇到错误 AddWithValue 不是 MySql.Data.MySqlClient.MySqlParameter 的成员

这是我的代码:

    Dim bn As String = ""
    Dim bottles As Integer = 0

    Dim SQLStatement As String = "UPDATE patient SET number_of_bottles = @bottles WHERE bednumber = @bednumber"

    Using cnn As New MySqlConnection("Server=localhost; database=patientinfo;user id=root;password=")
        Dim cmdn As New MySqlCommand(SQLStatement, cnn)
        cmdn.Parameters.AddWithValue("bottles", bottles)
        cmdn.Parameters.AddWithValue("bednumber", bn)
        cnn.Open()
        cmd.ExecuteNonQuery()

    End Using

我是 VB.net 和 MySql 的新手。任何帮助,将不胜感激。谢谢 ! :)

最佳答案

您必须使用在参数中使用的名称(缺少 @ 符号):

cmdn.Parameters.AddWithValue("@bottles", bottles)
cmdn.Parameters.AddWithValue("@bednumber", bn)

关于mysql - AddWithValue 不是 MySql.Data.MySqlClient.MySqlParameter VB.net 的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11940383/

相关文章:

mysql - VB.NET 如何通过检查数据库保存日期来创建提醒

vb.net - 使用 Splashscreen VB.NET 加载另一个表单

php - 使用 PHPExcel 从 MySQL 获取字段名称到 Excel

php - 如何将数据库中的图像调成每行10张图像?

mysql - Wordpress - 建立数据库连接时出错 - 全新安装 WP

mysql - 如何在 MySQL 中使用 IF 语句设置 WHILE 循环?

mysql - 如何在 Crystal 报表中左连接mysql?

vb.net - 如何在 Visual Basic 中将 Mat 和标量与 EmguCV 相乘?

vb.net - 使用 Int 调用的不带参数的字符串函数应该会失败构建

mysql - 如何从mysql准备语句中选择返回值?