VB 6.0 - How to connect MySQL Database

In this VB 6.0 tutorial we will share about How to connect MySQL Database in VB 6.0. Please following below steps :

Please makesure your Xampp App is running.
Open your browser
http://localhost/phpmyadmin
Create database : dbtm
Create table : TBL_SUPPLIER

Click start in your computer
Open control panels
Data Sources (odbc)
 Click Add

Select : MySQL ODBC 3.51 Driver
Click Finish
Data Source Name : ConnectDBTM
User : root
Database : dbtm

Open your Visual Basic 6.0
Design form1 like below picture :

VB 6.0 - How to connect MySQL Database

Place code below at form1
Dim Conn As New ADODB.Connection
Dim RSSupplier As ADODB.Recordset
Sub OpenDB()
Set Conn = New ADODB.Connection
Set RSSupplier = New ADODB.Recordset
Conn.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=ConnectDBTM"
End Sub
Private Sub Form_Load()
Call OpenDB
Adodc1.ConnectionString = Conn
Adodc1.RecordSource = "tbl_Supplier"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Run your project and below for the result
VB 6.0 - How to connect MySQL Database

Related Posts :

1 Response to "VB 6.0 - How to connect MySQL Database"