我尝试将 MySql 连接器用于 vb.net,但我总是遇到相同的错误,即
无法连接特定主机
我使用这段代码:
Imports MySql.Data.MySqlClient
Imports MySql.Data
Imports MySql
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myConnectionString As String
myConnectionString = "server=example.net;" _
& "uid=example_support;" _
& "pwd=passwordhere;" _
& "database=example_support;"
Try
Dim conn As New MySql.Data.MySqlClient.MySqlConnection(myConnectionString)
conn.Open()
Catch ex As MySql.Data.MySqlClient.MySqlException
Select Case ex.Number
Case 0
MessageBox.Show("Cannot connect to server. Contact administrator")
Case 1045
MessageBox.Show("Invalid username/password, please try again")
Case Else
MessageBox.Show(ex.Message)
End Select
End Try
End Sub
End Class
这个错误可能有什么问题???