Link to home
Start Free TrialLog in
Avatar of T1Tower
T1Tower

asked on

Is there a way to connect vb5 to mysql

Hello experts.
We have a very old development in vb5 and we want to know if there is a way to connect to mysql from vb5, we have found many examples on how to connect from vb6 but we have vb5.
Avatar of arnold
arnold
Flag of United States of America image

Mysql ODBC Connector should do the trick.
The ODBC interface is what your VB5 app will query.
http://dev.mysql.com/doc/refman/5.0/en/connector-odbc-usagenotes-apptips.html#connector-odbc-usagenotes-apptips-microsoft-visualbasic
Avatar of T1Tower
T1Tower

ASKER

Thank you Arnold.   Yes the odbc connection can connect to the mysql server.
How can I connect in VB5 to the ODBC ?
I ran cc.exe from  http://www.microsoft.com/download/en/details.aspx?id=1953
and it says im ok with mdac 2.8 sp1 (wxp sp2)
but I cannot get vb5 to connect to ODBC  how can I do that ?
Hi,

This is to create ODBC for MySQL, http://www.connectionstrings.com/mysql refer to MyODBC.

If you do not have idea how to call ODBC from your code, this one might help, http://www.avdf.com/may97/art_odbcdirect.html

BTW, just out of wonder, why not try to at least move to VB6.
DSN or DSNless?
http://www.vbmysql.com/articles/vbnet-mysql/myodbc-connector
http://www.connectionstrings.com/ from the above link

http://dev.mysql.com/doc/refman/5.1/en/connector-odbc-examples-programming.html

What does your code look like?

Been a while, but VB5/VB6 were somewhat similar with VB6 had some enhancements in addition to including function parameter info.
Avatar of T1Tower

ASKER

khairil:
+ I have the string, i dont have adodb.connection in vb5
+ we cannot change to any other version because some requirements.

Arnold:
My code looks like the sample:

Dim myconn As New ADODB.Connection    <---- it stops here. user defined type not defined.
Dim myrs As New Recordset
Dim mySQL As String
Dim myrows As Long

myconn.Open "DSN=MyODBCsample"
mySQL = "SELECT * from user"
myrs.Source = mySQL
Set myrs.ActiveConnection = myconn
myrs.CursorLocation = adUseClient
myrs.Open
myrows = myrs.RecordCount

myrs.Close
myconn.Close

I dont have any reference to ado in VB in VB5, how I do that?
Avatar of T1Tower

ASKER

I also tested this example:
http://dev.mysql.com/doc/refman/5.0/es/myodbc-examples-programming.html

it stops in the same place with:  [user defined type not defined.]
Dim conn As ADODB.Connection  
Avatar of T1Tower

ASKER

I can connect to mysql using excel and the connection tester, but I need to connect to mysql from VB5

In vb5 I dont have the adodb reference.  How do I do that ?
Avatar of T1Tower

ASKER

I just got the msadodc.ocx file, I ran regsvr32 and when adding it i get the message "License information for this component not found, you do not have an appropriate license to use this functionality in the design environment."
I Ran vb5cli and vb6cli, no luck.
ASKER CERTIFIED SOLUTION
Avatar of khairil
khairil
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of T1Tower

ASKER

that was it Khairil. I didnt had the reference to microsoft activex data object.
after that I connected perfectly.
Avatar of T1Tower

ASKER

your advice is not to use what type of controls Khairil ?

Arnold, do you have a sample to doit with odbc ?
ODBC is the driver you use to have your system interact , ADO etc is the interface to system resources like ODBC.
Avatar of T1Tower

ASKER

Thank you!.
Avatar of T1Tower

ASKER

Thank you Arnold for all your input.
Thank you khairil for all your input.
It is about build in VB5 DATA controls. Which you are not using it in this case.

Happy coding then.