[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

.net and mysql database connection

Hi,
need a working example of a connection between .net and mysql, mysql is located on a server over the internet, can such connection happen? i have the URL of the remote server.
do i need a special driver to do that??
Thanks
0
mte01
Asked:
mte01
  • 2
3 Solutions
 
razorback041Commented:
0
 
tpwellsCommented:
You can use the MySql .NET connector.

http://www.mysql.com/products/connector/net/

Refence the dll to your project and add

Imports MySql.Data.MySqlClient

to the top of your .vb file

You can then open a connection like this
Dim cn as New MySqlConnection("SERVER=addressToServer;DATABASE=databasename;UID=username;PASSWORD=password")
cn.Open()

You can then create MySqlCommand object and MySqlDataReaders and MySqlDataAdapters which all behave like the standard System.Data.SqlClient / System.Data.OleDB / System.Data.ODBC providers

Hope this helps
0
 
tpwellsCommented:
oh the second part of your question:

you do not need extra drivers to access the server you will need the server and the port address. The above connection string:

"SERVER=addressToServer;DATABASE=databasename;UID=username;PASSWORD=password;"

uses the default port of 3306 you can specify a port by adding

Port=number;

to the string
0
 
mte01Author Commented:
>> razorback041,tpwells

I was able to make the connection....Thanks for your help!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now