[56K WARN] VB6 - Connecting to a MySQL database

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

[56K WARN] VB6 - Connecting to a MySQL database

Post 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:

Image

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.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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 ;)
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post 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.

Image
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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>
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post by Trenchant »

Well I haven't seen that tutorial yet and it looks like a good one. Thanks for the help you could offer. :D
crouse
Forum Newbie
Posts: 13
Joined: Mon Dec 27, 2004 11:14 pm
Location: Sacramento, CA
Contact:

Post 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
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post by Trenchant »

Being new to VB I'm not sure what you mean. Heres a ss of the script and my references properties.

Image
crouse
Forum Newbie
Posts: 13
Joined: Mon Dec 27, 2004 11:14 pm
Location: Sacramento, CA
Contact:

Post 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
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post by Trenchant »

Sorry for such a late reply. I have been swamped lately and I just got finished dealing with a virus :roll:

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
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post 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.
Post Reply