Solved

MySQL VB ADO connection with mySQLProv

Posted on 2004-10-14
13
3,502 Views
Last Modified: 2013-12-25
I have developed a program in VB6 connecting to an SQL server using ADO and the OLEDB provider. Now I want connect to a mySQL server. The only option next to using ODBC is by my knowledge mySQLProv. I have 2 problems with this provider:
1) When I use the connection.Open with the following connection string (or any other):
         connection.Open "Provider= mysqlprov;" & _
             "Server = Localhost" & _
             "DataBase= myDB;" & _
             "Uid = myUser;Pwd = myPW;"
 I get a popup screen "MySQL data source Name Set up" where I have to fill in the same data. Is there any way around this?

2) When I fill the data I am able to connect to the database but I am getting some problems with SQL statements that do work in mySQL directly but not via the connection:
a) tablenames longer than 19 characters generate an error
b) JOIN expressions do not seem to work?
Can anybody shed some light on this?
Thanks in advance,
Jurriaan
0
Comment
Question by:J_code
  • 5
  • 3
  • 2
  • +1
13 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 12308997
Try this:

oConn.Open "Provider=MySQLProv;" & _
           "Data Source=mySQLDB;" & _
           "User Id=myUsername;" & _
           "Password=myPassword"

and take a look here:

http://www.coveryourasp.com/Snippet.asp?snip=16

Leon
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 12309008
MySQL Reference Manual:

http://dev.mysql.com/doc/mysql/en/index.html

Leon
0
 

Author Comment

by:J_code
ID: 12316439
Still getting the popup screen. I have tried several connection strings, when I enter a datasource the fields 'datasource' and 'Database' are filled with the data source name (see code below), otherwise fields are empty.
         connTraceLab.Open "Provider= MySQLProv.2.5;" & _
             "Server = Localhost; Data Source = myDB;" & _
            "DataBase= myDB;" & _
             "User Id = myUser;Password = myPWD;"


The reference manual doesn't really answer my questions. There is no mention of mySQLProv and the only reference to OLEDB is: "If you have problem with MyODBC and your program also works with OLEDB, you should try the OLEDB driver. "

It is important for me to know whether 'JOIN' expressions can be used with mySQLProv, if this is not possible I can quit this exercise...
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Accepted Solution

by:
samtyf earned 250 total points
ID: 12317382
Why not have a try on the MySQL ODBC Connector 3.51? Download it from here

http://dev.mysql.com/downloads/connector/odbc/3.51.html

The code in VB is

Connection.Open "Driver={MySQL ODBC 3.51 Driver};Server=10.10.10.10;uid=userid;pwd=userpasswd;database=databasename"

Regards,
Sam Tan
0
 

Author Comment

by:J_code
ID: 12317559
Thanks Sam, however I am not so keen on using ODBC for a multi user environment..

Anyway I found a new version of myOLEDB (mysqlprov 3.0) which solves part 2 of the problems mentioned above. JOIN and tablename length are no longer a problem!

The pop up screen still appears when connecting however. It seems I am not able to fill the mySQL host from the connection string (Username and password are filled now and as dataSource '[Default]' is entered). Any suggestions?

Jurriaan

0
 

Author Comment

by:J_code
ID: 12317613
Problem solved!
The following connection string worked:
         conn.Open "Provider= MySQLProv.3.0;" & _
             "Data Source = myDB; " & _
             "Database = myDB;" & _
             "User Id = myUser;Password = myPW; option = 3"
Thanks for helping.
Jurriaan
0
 

Author Comment

by:J_code
ID: 12320385
It turns out that the myOLEDB is not so useful for me after all. Transactions and single row locking are not supported and apparently the myOLEDB is no longer in development (see
http://www.experts-exchange.com/Databases/Mysql/Q_20732567.html)

So I will go with Sams' suggestion and try the myODBC. One question though. Do you have to install myODBC.exe on each client or can you just use a dll?

J.
0
 

Expert Comment

by:samtyf
ID: 12326386
Hi Jurriaan

So far, i'm installing the myODBC in each client machine. But i'm not sure it can or cannot to just use a dll without the myODBC Installation. :)

Regards,
Sam Tan
0
 

Author Comment

by:J_code
ID: 12816899
OK, since I am using the myODBC I'll award Sam with the points.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 12822931
To do that, click the "Accept" button next to his post.  Thanks. -- Dan
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 12830033
DanRollins,

I am assuming you are taking care of this.

Leon
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question