[英]Can't connect to mysql database
VB.NET Express 2010. 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
I have imported MySql.Data.MySqlClient too: 我也导入了MySql.Data.MySqlClient:
Imports MySql.Data.MySqlClient
But when I click the button, the whole application just freezes. 但是,当我单击按钮时,整个应用程序将冻结。
I have added the reference to MySql.Data.dll. 我已经添加了对MySql.Data.dll的引用。 The path:
路径:
C:\Program Files\MySQL\MySQL Connector Net 6.4.4\Assemblies\v4.0\MySql.Data.dll
Such file was installed from an installer downloaded from http://dev.mysql.com/downloads/connector/net/ 此类文件是通过从http://dev.mysql.com/downloads/connector/net/下载的安装程序安装的
Why is that? 这是为什么?
如果尚未更改连接字符串的server
参数以指向本地安装,则可以解释为什么挂起它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.