470,636 Members | 1,365 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

MySQL and ADO

I am looking at using MySQL in my application (currently works with Access
and SQL Server 2000).

Is it possible to access MySQL database using ADO?

What is the connection string for this?

Also, it is possible to change/modify the table structure/create new
tables/indexes via Visual basic codes?

Any help greatly appreciated.

Tks
JY


Dec 8 '05 #1
1 13743
"zMisc" <yo********@hotmail.com> wrote in message
news:F5******************@news-server.bigpond.net.au...
I am looking at using MySQL in my application (currently works with Access
and SQL Server 2000).

Is it possible to access MySQL database using ADO?
Of course :-)
You will want the MySQL ODBC driver available at
http://dev.mysql.com/downloads/
Look for "Connector/ODBC 3.51"
-download, then install.
What is the connection string for this?
First use the Windows control panel _administrative Tools_Data Sources
(ODBC) dialog to "Add" a new System DSN (Data Source Name). When you select
the "MySQL ODBC 3.51" driver, you get a dialog box to fill in relevant
information and select parameters for a connection. Hit the [Test] button
to see if you can connect.

Now you have a DSN you can use to connect. You can use that just fine. But
if you want to code lower,this is what I do to "discover" a proper
connection string. I use Access as a tool.

1) create a new query in design view.
2) right click in the design panel and from the submenu select "SQL
Specific- PassThrough". This get's you a blank window to enter sql text.
3) Right click on the window title bar and select [Properties] from the sub
menu.
4) Plant your cursor in the "ODBC Connect Str" box.
5) Click on the dialog expansion button to the right.
6) Pick the "Machine Data Sources" tab from the dialog box that pops up.
7) Select the DNS that you created above.
8) When it asks you to save the pasword in the connection string - say yes.

Now a complete and proper connection string is entered for you in the text
box. I just copy that.

I do suggest you enter a simple query and test it to be sure the connection
string works.

ODBC;DATABASE={default database name};DESCRIPTION={some optional
description};DRIVER=MySQL ODBC 3.51 Driver;
OPTION={nnnn};PWD={password};PORT={nnnn};SERVER={n n.nn.nnn.nn};UID={user
name}

This rigamarole is particularly useful to get at that OPTION integer value.
It is determined by the options you set when you created the DSN using the
ODBC setup dialog. I know of no other way to figure out what that integer
value should be, although it's probably documented somewhere :-) Were it
not for that mystery, I could just fill in the connection string by hand.
Also, it is possible to change/modify the table structure/create new
tables/indexes via Visual basic codes?


I'm not sure how how much you can get away with using VB, ADODB and ADOX
libraries.
But what you can *always* do is pass SQL statements *directly* to MySQL.

You can define pass-through queries in Access and create PassThrough type
recordsets in VB which simply pass along your SQL to MySQL with no
interpretation by Microsoft software at all. This means that any legal
MySQL statements can be executed.

- which means you can do anything MySQL permits :-)
Thomas Bartkus

Dec 8 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by mikey | last post: by
reply views Thread by Yun Guan | last post: by
reply views Thread by Mike Chirico | last post: by
2 posts views Thread by Saqib Ali | last post: by
2 posts views Thread by trihanhcie | last post: by
1 post views Thread by Korara | last post: by
???
reply views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.