Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connect to a MySQL database residing locally. 1

Status
Not open for further replies.

ACH381

Technical User
Apr 3, 2002
49
US
Using Microsoft Word - how do I connect to a MySQL database residing locally on my computer so I can import information from MySQL to a Word FormField?

An example of the path: C:\InetPub\mshpar\cgibin\ar_person.def
 
Assuming you have installed the myODBC 2.50 or 3.51 driver, then in the Visual Basic Editor (Alt+F11 while in Word), you need to go to Tools-->References and add "Microsoft ActiveX Data Objects 2.7 Library". The 2.6 or 2.5 Library should also work, just choose the highest number that you have available.

The following should get you connected, after that it's pretty much like any other database.

Dim conn As ADODB.Connection
'connect to MySQL server using MySQL ODBC 2.50 Driver
Set conn = New ADODB.Connection

conn.Open "Driver={mySQL};" & _
"Server=localhost;" & _
"Option=16835;" & _
"uid=root;pwd=MyPassword;database=MyTestDB;"


Of course you'll need to change the user id, password and database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top