所以每次我尝试写入数据库时,在 MySQL 上运行程序都会发出错误(致命的内部连接错误)。
这是正在使用的代码:
Dim SQLcon As New SqlConnection("Server=127.0.0.1; Database=storedatabase; User Id=root; Password=root;")
Dim cmd As SqlCommand
Try
SQLcon.Open()
cmd.Connection = SQLcon
cmd.CommandText = "INSERT INTO Items (ItemName, ItemPrice, ItemQTY) VALUES ('" & Item & "','" & Price & "','" & Qty & "');"
SQLcon.Close()
MsgBox("Added " & Item & " to Database", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox(ex.Message)
End Try
VB给出了这个错误:
An exception (first chance) of type 'System.InvalidOperationException' occurred in System.Data.dll.
SQL 端口更改为 1433。
存在带有表的数据库。
编辑:将 Port=1433 添加到连接字符串后,我收到此错误:
InnerExecption = {"Keyword not supported: 'port'."}
连接字符串:
Dim SQLcon As New SqlConnection("Server=127.0.0.7; Port=1433; Database=storedatabase; User Id=root; Password=root;")