How to use Visual Basic to connect to MySQL

From DreamHost
Jump to: navigation, search

This topic deserves a step by step as it seems it would be a common need. In any event I just went through the steps so here they are. I am working from memory so I may miss a few details here and there. Either ping me or write in the added detail yourself -- google->embeddedrf

Initial conditions: I run windows 98 and have an MySQL database on DreamHost and want to connect with Visual Basic
Debug Sequence used: I used 3 separate VB source codes from http://www.Planet-Source-Code.com Various problems were solved during play with each sequential script. I will give you my best guess with regards which did what.

Because I use Windows 98 I had to get and updated version of msado26.tlb
I found that if I downloaded their MDAC 2.8 update that it had what I needed. --I did this by going to: http://support.microsoft.com/?kbid=828396
Here I could see that it had msodo26.tlb
--Then I went here and read more http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmdac/html/data_mdacinstall.asp
--The finally to download this from:
http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&DisplayLang=en
I installed this update from Microsoft. When I check the directory I could see:
C:\program files\common files\system\ado\msado26.tlb
Missing tlb file solved.
First VB app from Planet Source Code run: LearnMySQL
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=53471&lngWId=1
When I tried to run this code it flagged the most common error according to Microsoft.
Microsoft OLE DB Provider for ODBC Drivers error 80004005 [Microsoft][ODBC Driver Manager]Data source name not found and no default driver specified.
You can read about this a solution: http://support.microsoft.com/kb/306345/EN-US/
While this made it evident that there was trouble with the registry settings its terminology was ambiguous so I looked for another option. Something needed set in the registry. I viewed some of the relevant keys. Rather than edit by hand guessing at the ambiguous terminology in the naming of keys I used another downloaded VB code. This code is described as follows: Allows you to programmatically create an ODBC connection to a MySQL database using the Registry API.
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=53341&lngWId=1&txtForceRefresh=731200619473277198
I ran it and set the relevant quantities: My SQL server,MySQL ID,Password,MySQL password, MySQL Database Name and the rest I left alone hoping for the default settings to work.
Next I downloaded and installed the MyODBC3.51 driver from MySQL.com
http://dev.mysql.com/downloads/connector/odbc/3.51.html
After that I was flagged an error that seemed like it did not like my login password. This is the error flagged:
A MySQL Connection Error has been returned:[MySQL][ODBC 3.51 Driver]Access denied for user embeddedrf@ip67-4-162-63(using password:YES)[-2147468259]

This is because DreamHost requires you set up the IP address the user will work from in the WebPanel interface. Do this and it works finally !