Problem solve Get help with specific problems with your technologies, process and projects.

Integrating and operating VB with MySQL

I am working on a project, building an application in VB, and MySQL is its database. Can you offer any tips on finding and using the code to connect VB to the MySQL database? Can VB apps and MySQL work together well? Also, how do I call the record set and add, delete and update in VB to the MySQL database?
MySQL and VB work well together, using MySQL Connector/ODBC for VB6 and Connector/NET for VB.NET. The connectors are available for download.

As for tip and tutorials, I will shamelessly plug a site I started back in 2003 called www.vbmysql.com. At the site you can find a good-sized archive of sample code and a series of articles regarding using Visual Basic and MySQL together.

Here's a basic example of inserting data using VB6 with MYSQL from the site's sample code collection:

 Dim conn As ADODB.Connection
    Set conn = New ADODB.Connection
 Dim rs As ADODB.Recordset
 Set rs = New ADODB.Recordset

 conn.CursorLocation = adUseClient
 conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
       & "SERVER=;" _
       & "DATABASE=test;" _
       & "UID=testuser;" _
       & "PWD=12345;" _
       & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384


 rs.Open "SELECT * FROM mytable WHERE 1=0", conn, adOpenStatic, adLockOptimistic

 rs!Name = "Johnny Bravo"
 rs!address = "Mama's House"

 txtID.Text = rs!person_id
 Set rs = Nothing
 Set conn = Nothing

Dig Deeper on Linux servers