NET连接到mysql数据库

NET连接到mysql数据库

本文介绍了从VB.NET连接到mysql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从Visual Studio 2010建立与mysql数据库的工作连接时遇到一些麻烦。
下载并安装mysql-net连接器后,我在Xampp中设置了一个简单的测试数据库,位,直到我设法从数据库读取一些值并插入新的。



现在我试图访问远程服务器上的另一个数据库,我得到的是一个错误消息:

基本上,我只是试图执行这段代码:

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



(服务器ip看起来有点不同)



当我访问本地数据库,它看起来很相似:

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

然而,我可以使用简单的PHP脚本轻松访问远程数据库...没有问题。



任何想法如何解决这个问题? : - /

解决方案

尝试使用以下连接字符串 -

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

指定您需要的值 - 主机名,端口,密码...


I'm having some trouble setting up a working connection 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:

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? :-/

解决方案

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...

这篇关于从VB.NET连接到mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 15:53