Thursday, 25 June 2015

VB6.0 :: SOURCE CODE KONEKSI DATABASE DENGAN ADODB DI VB6.0



Option Explicit
Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Dim mvBookMark As Variant

Public Sub Koneksi()
'buat string koneksi baru ke database
Set conn = New ADODB.Connection
'buka string koneksi ke database target
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\dbMedis.mdb;Persist Security Info=False"
'tentukan lokasi korsur sebagai client
conn.CursorLocation = adUseClient
End Sub

Sub tampilDataGrid()
'buka tabel Latihan
rs.Open "select * from TRANS_CEK_MEDIS", conn
'baca tabel anggota hingga record terakhir
With rs
 If Not (.BOF And .EOF) Then
 mvBookMark = .Bookmark
 End If
End With
'hubungkan datagrid ke tabel Latihan
Set DataGrid1.DataSource = rs.DataSource
End Sub



Private Sub Form_Load()
Call Koneksi
Call tampilDataGrid
End Sub

No comments:

Post a Comment