Page 1 of 1
[56K WARN] VB6 - Connecting to a MySQL database
Posted: Thu Jan 06, 2005 11:31 pm
by Trenchant
Does anyone know how I would go about connecting to a MySQL database with Visual Basic 6? I have tried ODBC with no success. Heres a ss of the application I'm in need of it for:
Its a program where serverowns can manage their webhosting clients. the top box allows them to search through their clients and the bottom section displays their information.
Posted: Thu Jan 06, 2005 11:33 pm
by markl999
I have done this in the past but can't remember the details. All i can do is point you to
http://www.cgi-interactive-uk.com/vb6_c ... mysql.html which seems to help if you've not already found this link

Posted: Thu Jan 06, 2005 11:42 pm
by Trenchant
I have tried tutorials like that but I dont think the driver is installing right. It never actually works. I have downloaded tutorial source codes that are said to be ready and working demos but they have the same error as my script.

Posted: Thu Jan 06, 2005 11:50 pm
by markl999
Well that's my VB knowledge exhausted (i overwrote it with Delphi) but that doesn't look like a connection error to me but an actual syntax/coding one, but i could easily be wrong. </no help at all>
Posted: Fri Jan 07, 2005 12:08 am
by Trenchant
Well I haven't seen that tutorial yet and it looks like a good one. Thanks for the help you could offer.

Posted: Fri Jan 07, 2005 2:24 am
by crouse
As a Visual Basic Developer I will attempt to help you get your program working. This might seem like a stupid question, however the error that you are getting makes me think that it needs to be asked. Have you created a reference to the ADO library? I would suggest using either 2.6 or greater. The reason that I ask this question is that the error that you are getting has nothing to do with trying to connect to the database. Visual Basic is telling you that it can not resolve the variable type that you are declaring. The message box is covering up the rest of the line so I can not be sure. However, that is where I would start first.
Chris
Posted: Sat Jan 08, 2005 12:00 am
by Trenchant
Being new to VB I'm not sure what you mean. Heres a ss of the script and my references properties.

Posted: Sat Jan 08, 2005 4:05 am
by crouse
Sorry I was not more specific. The reference that you are looking for is specifically:
Microsoft ActiveX Data Objects 2.x Library.
Let me know if this helps any.
Chris
Posted: Wed Jan 12, 2005 10:11 pm
by Trenchant
Sorry for such a late reply. I have been swamped lately and I just got finished dealing with a virus
I got the script working FINALLY! but the dam virus took out my webserver!!! JUST when I finished the script.
I got rid of all the errors but I had to change something which I didn't really want to and I'm in need of another way around this...
In order to report the data from the database to the text field I had to change my text field to a data link which I was not planning on doing. Once I get my webserver back running at 100% I can test the scripts all the way but right now I can get through all scripting errors until I run into a "Cannot connect to database"(webservers down).
Anyway heres the code. I just can't figure out what .someting tag to add to the database select variable. That sounds confusing to even me so I will explain it in the code...
Code: Select all
Option Explicit
Public recsetEmployees As Recordset
Public dbEmployees As Database
Dim temp As Variant
Private Sub Form_Load()
Set dbEmployees = OpenDatabase("", dbDriverComplete, False, "ODBC;DSN=localhost;UID=***;PWD=***;Database=serverpro")
Set recsetEmployees = dbEmployees.OpenRecordset("employees", dbOpenDynaset)
' This is where I run into the problem. I can't change data1.recordset to the name of my txt field(with .Text ending) It comes up with an error saying like invalid data type.
Set Data1.Recordset = recsetEmployees
End Sub
Posted: Mon Jan 17, 2005 7:47 pm
by Trenchant
I'm still getting a cannot connect to database error. Any ideas? My websites connecting to the same server with the same username, password combo fine.