Solved

MySQL VB ADO connection with mySQLProv

Posted on 2004-10-14
13
3,472 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

708 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

12 Experts available now in Live!

Get 1:1 Help Now