Knowledgebase: Databases
Connection String Examples for MySQL
Posted by Paul Woodland (Import) on 02 December 2006 04:35 AM

These examples use "sql05" as the server address. Some customers may be on a different server, and have a different address to replace this with. Our control panel will show you what the server address is for your specific database.

 

Connecting in .Net using MySQL Connector/Net
This code will only work with in VB.Net, you should enter your own database, username & password in the correct place:

Dim Conn as New MySql.Data.MySqlClient.MySqlConnection("Server=sql05;Database=DATABASENAME;Uid=USERNAME;Pwd=PASSWORD;")

This code will is the equivalent for C#:

MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection("Server=sql05;Database=DATABASENAME;Uid=USERNAME;Pwd=PASSWORD;")



Recommended ODBC Connection String (can be used in ASP, ASP.Net etc)
Remember to enter your own database, username & password in the correct place:

DRIVER={MySQL ODBC 8.0 Unicode Driver};SERVER=sql05;DATABASE=DATABASENAME;USER=USERNAME;PASSWORD=PASSWORD;OPTION=3



Alternative ODBC Connection String (can be used in ASP, ASP.Net etc)
This uses the ANSI version of the driver, instead of the unicode version. Remember to enter your own database, username & password in the correct place:

DRIVER={MySQL ODBC 8.0 ANSI Driver};SERVER=sql05;DATABASE=DATABASENAME;USER=USERNAME;PASSWORD=PASSWORD;OPTION=3
(167 vote(s))
Helpful
Not helpful

Comments (0)