View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
[email protected][_2_] gimme_this_gimme_that@yahoo.com[_2_] is offline
external usenet poster
 
Posts: 236
Default macros to query a database

Ummm.

In my Workbook I have a dropdown that allows the user to select either
a development or production database. The dropdown is on a sheet named
Home.

Here do this:

The first thing you need to get is your MySql connection string.

To get that create a file in some folder, say your C: drive.

Give it any name but give it a udl suffix.

Such as C:\mysql.udl

Go into IE file Explorer and right click on that file.

Fill out all the information on all the tabs.

Then mysql.udl will have the connection string.

Edit mysql.udl with NotePad - copy and paste.

Then swap out the definition of OpenConnection() that I gave you with
my customizations
and swap it for this version:


Public Sub OpenConnection()
Dim dbsource As String
Dim username As String
Dim password As String
dbsource = "your udl connection string"
username = "your mysql username"
password = "your mysql password"
Set m_connection = CreateObject("ADODB.Connection")
m_connection.CommandTimeout = 2000
m_connection.Open dbsource, username, password

End Sub