Solved

MySQL VB ADO connection with mySQLProv

Posted on 2004-10-14
13
3,491 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now