开发者

Connecting to mysql database from VB.NET

开发者 https://www.devze.com 2023-04-06 08:04 出处:网络
I\'m having some trouble setting up a working conn开发者_JS百科ection to a mysql database from Visual Studio 2010.

I'm having some trouble setting up a working conn开发者_JS百科ection to a mysql database from Visual Studio 2010. After downloading and installing the mysql-net connector, I set up a simple testing database in Xampp and experimented around a bit until I managed to read some values from the database and inserting new ones.

Now I'm trying to access another database on a remote server and all I get is an error message:

Unable to connect to any of the specified MySQL hosts.

Basically, I'm only trying to execute this code:

Dim con As New MySqlConnection("Server=111.11.111.111;Uid=root;Pwd=mypwd;Database=mydb;")
con.Open()
con.Close()

(server ip looks a bit different of course)

When I access my local database, it looks quite similar:

Dim con As New MySqlConnection("Server=127.0.0.1;Uid=root;Pwd=;Database=test;")
con.Open()
con.Close()

Nevertheless, I can access the remote database easily using a simple PHP script... no problems there.

Any ideas how to fix this? :-/


From the documentation for MySql on connectionstrings.com, it looks like the default port is 3306.

Make sure the firewalls on the machines and between them allow traffic through this port.


Try to use connection string like this -

Host=host_name;User Id=root;Port=3306;Database=test;Password=pwd

Specify values you need - host name, port, password...

0

精彩评论

暂无评论...
验证码 换一张
取 消