VB.NET Express 2010。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connection As MySqlConnection
connection = New MySqlConnection()
connection.ConnectionString = "Server=example.com; Uid=***; Pwd=***; Database=***;"
Try
connection.Open()
MessageBox.Show("Connection Opened Successfully")
connection.Close()
Catch mysql_error As MySqlException
MessageBox.Show("Error Connecting to Database: " & mysql_error.Message)
Finally
connection.Dispose()
End Try
End Sub
我也导入了MySql.Data.MySqlClient:
Imports MySql.Data.MySqlClient
但是当我点击按钮时,整个应用程序就会冻结。
我添加了对MySql.Data.dll的引用。路径:
C:\Program Files\MySQL\MySQL Connector Net 6.4.4\Assemblies\v4.0\MySql.Data.dll
此类文件是从http://dev.mysql.com/downloads/connector/net/
下载的安装程序安装的为什么?
答案 0 :(得分:0)
如果您尚未将连接字符串的server
参数更改为指向本地安装,则可以解释为什么它会挂起。