2013-04-11 81 views
0

請幫忙,什麼毛病我vb.net代碼在一個MySQL數據庫插入數據到MySQL與VB .NET

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 
+0

您能否提供一些指示說明您正在解決的問題? – Pezzzz 2013-04-11 10:05:13

回答

0

我認爲你必須像 昏暗CMD1作爲指定引用的值插入值New MySqlCommand(「INSERT INTO configs(configType,portsStatus,bandwidthLimit,ports,user)values('@ config','@manage','@limit','@ports','@user')」,conn)

0

用戶我是保留字,請嘗試將其放在方括號中:

Dim cmd1 As New MySqlCommand("INSERT INTO configs(configType, portsStatus, bandwidthLimit, ports, [user]) values(@config, @manage, @limit, @ports, @user)", conn)