我和我的信息学课程中的'团队'一直试图让程序运行并将其连接到SQL服务器,似乎我们不断收到错误。你能不能帮我解决问题,我一直试图解决这个问题,所以欢迎任何帮助。
我们到目前为止的代码:
Try
Dim conn As New MySqlConnection
Dim test As String = 64012478
conn.ConnectionString = "User ID=*****_****; Password=******; Initial Catalog=dainformat_idea; Data Source=(IP of website);"
conn.Open()
Dim query = "SELECT * From students"
Dim commando As New MySqlCommand(query, conn)
Dim reader As MySqlDataReader = commando.ExecuteReader
reader.Read()
If reader.HasRows Then
MessageBox.Show(reader(0) & " " & reader(1) & "Kaas")
Exit Sub
Else
MessageBox.Show("Could not find something")
Exit Sub
End If
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try`
答案 0 :(得分:3)
您正在尝试将SQL Server与MySQL库连接...如果您在服务器上安装了mySQL,代码将运行正常,但只有您拥有mysql,否则连接将失败。