我如何连接到c#或VB中的在线mysql数据库 [英] how do i connect to online mysql database in c# or VB

查看:91
本文介绍了我如何连接到c#或VB中的在线mysql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



i希望连接到在线mysql数据库...



i有这个信息:





PHPmyAdmin url like:172.53.162.40/phpmyadmin(这是我访问所有数据库的网址

也是用户并传递进入此域名,如:

hi all

i want connect to online mysql database ...

i have this information :


PHPmyAdmin url like : 172.53.162.40/phpmyadmin (this is a url that i access all database
also user and pass for enter to this domain like:

User1 And Password1







database name : mygem
database user : uuu
password      : ppp



:::: NOW :::




:::: NOW :::

and my host supporter say : not exists any port for access my database ...



i从下面的代码用于连接字符串




i used from below code for connection string

string con="Server=172.53.162.40/phpmyadmin;Database=mygem;Uid=uuu;Pwd=ppp;";





但错误确认广告说:无法连接到mysql主机。 ...





but error accured ad say : can't connect to mysql host ....

How I Create Connection String For Connect to This Database ?



请帮帮我



非常感谢


please help me

thanks a lot

推荐答案

检查< a href =http://www.connectionstrings.com/mysql> http://www.connectionstrings.com/mysql [ ^ ],其中有示例如何撰写conn。 MySql的字符串。

还要确保,您正在使用合适的解决方案,如何从.NET连接到MySQL - MySQL .NET连接器 [ ^ ]。
Check http://www.connectionstrings.com/mysql[^], where you have examples how to compose conn. string for MySql.
Also make sure, you are using suitable solution, how to connect to MySQL from .NET - MySQL .NET connector[^].


有几个选项,你有什么要求让远程服务器和本地windows应用程序连接?这会降低你的系统速度吗?





选项1:你可能需要四处寻找能够启用遥控器的供应商访问



选项2:您可以拥有自己的ISP专用服务器,这样您就可以进行远程连接,与共享服务器选项1相比,这是昂贵的。
There are few options and what is your requirement to have the remote server and connect from local windows applicaiton ? this is going to slow down your system ?


Option 1: l you may have to shop around for any providers who will enable remote access

Option 2: You can have your own dedicated server with the ISP so that you can have remote connectivity and this is expensive compared to option 1 which is shared server.


首先,如果您使用MySQL,则需要从MySQL网站下载MySQL odbc驱动程序3.51驱动程序。然后,您需要使用您的CPANEl帐户从您的域或网站启用远程MySQL访问...



然后使用MySQL ODBC 3.51驱动程序连接到您的远程数据库使用VB.Net或C#应用程序中的连接字符串。



使用此连接字符串



服务器= myServerAddress;数据库= mydbfile; Uid = myUsername; Pwd = myPassword;



myServerAddress网站或域名地址eg.www.yahoo.com

mydbfile是您在cpanel帐户上创建的数据库的名称,您已允许远程访问该数据库,并且

myUsername和myPassword是用于连接远程mysql数据库的用户名和密码...



对于MS Access,您可以使用OLEDB连接连接到上传的Access数据库。

例如,如果您的网站是http://www.yahoo.com/db/mydbfile.mdb,那么您可以使用下面的此连接字符串的Microsoft.Jet驱动程序;你需要指定数据库的密码...



First of All you need to Download the MySQL odbc driver 3.51 driver from MySQL website if you are using MySQL. Then you need to enable Remote MySQL Access from your domain or website using your CPANEl Account...

You then use the MySQL ODBC 3.51 Driver to connect to your Remote Database using a Connection String from your VB.Net or C# Application.

Use this connection string

Server=myServerAddress;Database=mydbfile;Uid=myUsername;Pwd=myPassword;

myServerAddress website or domains address eg.www.yahoo.com
mydbfile is the name of the database you have created on you cpanel account that you have allowed remote access to and
myUsername and myPassword are the username and password that you will use to connect to your remote mysql Database...

For MS Access you can connect to your uploaded Access Database using an OLEDB connection .
For instance if your website is http://www.yahoo.com/db/mydbfile.mdb then you can use the Microsoft.Jet driver with this Connection String below; You need to Specify the password of your database if you have any...

Dim DatabaseFile as string = ????
Dim connection_builder As New OleDb.OleDbConnectionStringBuilder
connection_builder = New OleDb.OleDbConnectionStringBuilder
connection_builder.DataSource = Me.mydbfile
connection_builder.Provider = "Microsoft.Jet.OLEDB.4.0"
connection_builder.Add("Jet OLEDB:Database Password", Password)
Return New Data.OleDb.OleDbConnection(connection_builder.ConnectionString)





就是这样..如果你还有问题,请告诉我......



That's it.. In Case you still have problems let me know...


这篇关于我如何连接到c#或VB中的在线mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆