0

请帮忙,我的 vb.net 代码在 MySQL 数据库中插入值有什么问题

    Dim conn As New MySqlConnection(ConfigurationManager.ConnectionStrings("ibdm").ConnectionString)
    Dim cmd1 As New MySqlCommand("INSERT INTO configs(configType, portsStatus, bandwidthLimit, ports, user) values(@config, @manage, @limit, @ports, @user)", conn)
    Try
        conn.Open()
        cmd1.ExecuteNonQuery()
        iReturn = True
    Catch ex As MySqlException
        MsgBox(ex.Message.ToString)
        iReturn = False
    Finally
        conn.Close()
    End Try
4

2 回答 2

0

我认为您必须在报价中指定值,例如 Dim cmd1 As New MySqlCommand("INSERT INTO configs(configType, portsStatus, bandwidthLimit, ports, user) values('@config', '@manage', '@limit', '@端口', '@user')", conn)

于 2013-04-11T09:59:13.980 回答
0

用户 my 是保留字,尝试将其放在方括号中:

Dim cmd1 As New MySqlCommand("INSERT INTO configs(configType, portsStatus, bandwidthLimit, ports, [user]) values(@config, @manage, @limit, @ports, @user)", conn)
于 2013-04-11T10:04:46.030 回答