Please following below :
1. Built database DB.accdb
We have DB.accdb with Table Customer :
2. Open your VB 6.0 application
Design form like below picture
Copy DB.accdb include folder where you crated project VB 6.0
Place below code in form1 :
Dim Conn As New ADODB.Connection
Dim RSCustomer As ADODB.Recordset
Sub FormEmpty()
Text1 = ""
Text2 = ""
Text3 = ""
End Sub
Sub OpenDB()
Set Conn = New ADODB.Connection
Set RSCustomer = New ADODB.Recordset
Conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & App.Path & "\DB.accdb"
End Sub
Private Sub Form_Activate()
RSCustomer.Open "TBL_CUSTOMER", Conn
Combo1.Clear
Do Until RSCustomer.EOF
Combo1.AddItem RSCustomer!Customer_id
RSCustomer.MoveNext
Loop
End Sub
Private Sub Form_Load()
FormEmpty
Call OpenDB
Adodc1.ConnectionString = Conn
Adodc1.RecordSource = "TBL_CUSTOMER"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub Combo1_Click()
Call OpenDB
RSCustomer.Open ("Select * From TBL_Customer where Customer_id='" & Combo1 & "'"), Conn
If Not RSCustomer.EOF Then
Text1 = RSCustomer!Name
Text2 = RSCustomer!Address
Text3 = RSCustomer!Phone
End If
Conn.Close
End Sub
and the last, please run your projec
You can click here to download project / source code above
Next Article
« Prev Post
« Prev Post
Previous Article
Next Post »
Next Post »
Penulisan markup di komentar
- Untuk menulis huruf bold silahkan gunakan
<strong></strong>
atau<b></b>
. - Untuk menulis huruf italic silahkan gunakan
<em></em>
atau<i></i>
. - Untuk menulis huruf underline silahkan gunakan
<u></u>
. - Untuk menulis huruf strikethrought silahkan gunakan
<strike></strike>
. - Untuk menulis kode HTML silahkan gunakan
<code></code>
atau<pre></pre>
atau<pre><code></code></pre>
, dan silahkan parse dulu kodenya pada kotak parser di bawah ini.
Konversi Code
Silahkan Berkomentar Dengan
2 komentar
Write komentarbagaimana caranya bu untuk merubah ke versi db mysqlnya bu??
saya masih agak bingung

Hi Rian,
Pastikan kamu sudah belajar koneksi database VB 6.0 menggunakan DB MySQL ya, jika sudah tinggal kamu ganti koneksinya aja..
gampang kan :)
