Friday, June 26, 2009

Connection to MySQL Server using ADO

If you want to create an office or other applications and you want to connect to the MySQL server, you can use the code below to be connected with your MySQL server.

Dim cn as ADODB.Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "Driver={Mysql ODBC 3.51 Driver};" & _
"Database=yourdatabasename;" & _
"UID=youruserID;" & _
"PWD=yourPassword;" & _
"PORT=portyourserver;" & _
"OemToAnsi=No;" & _

yourdatabasename = name of the database will be used.
youruserID = Users ID can access a database that will be used.
Yourpassword = User ID's password.
portyourserver = Port your server.
yourservername = Name server that you want to use.

1 comment:

  1. Hi Evi,

    Have you used this code to connect to a MySQL 5 database?