• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

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.
0
T1Tower
Asked:
T1Tower
  • 9
  • 3
  • 3
1 Solution
 
arnoldCommented:
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
0
 
T1TowerAuthor Commented:
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 ?
0
 
khairilCommented:
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.
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
arnoldCommented:
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.
0
 
T1TowerAuthor Commented:
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?
0
 
T1TowerAuthor Commented:
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  
0
 
T1TowerAuthor Commented:
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 ?
0
 
T1TowerAuthor Commented:
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.
0
 
khairilCommented:
emmm... it seems that you are not failing on ODBC but on creating ADO object.

ADO object is not the OCX but it is DLL/TLB object (msado20.tlb), you should make references to this TLB. To make references just go to menu, Project -> References and select Microsot Active Data Objects from the list.

However, if you are using the DATA CONTROLS most likely the control will not using this ADO object but DAO. My advice is to avoid using this type of controls.

I have leave VB5 for long time ago, what I am suggesting you is as far as I can remember for past 13 years ago.
0
 
T1TowerAuthor Commented:
that was it Khairil. I didnt had the reference to microsoft activex data object.
after that I connected perfectly.
0
 
T1TowerAuthor Commented:
your advice is not to use what type of controls Khairil ?

Arnold, do you have a sample to doit with odbc ?
0
 
arnoldCommented:
ODBC is the driver you use to have your system interact , ADO etc is the interface to system resources like ODBC.
0
 
T1TowerAuthor Commented:
Thank you!.
0
 
T1TowerAuthor Commented:
Thank you Arnold for all your input.
Thank you khairil for all your input.
0
 
khairilCommented:
It is about build in VB5 DATA controls. Which you are not using it in this case.

Happy coding then.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 9
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now