Artikel ini lanjutan dari Part 1
Kode selengkapnya:
Option Explicit
Dim oConn As New ADODB.Connection
Dim rsData As New ADODB.Recordset
Dim strConn As StringDim SQL As String
Private Sub Form_Load()
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\latihan.mdb;" & _
"Persist Security Info=False"
ListTables
End Sub
Sub Open_Connection()
Set oConn = New ADODB.Connection
oConn.ConnectionString = strConn
oConn.Open
End Sub
Sub ListTables()
Open_Connection
Dim rs As ADODB.Recordset
List1.Clear
Set rs = oConn.OpenSchema(adSchemaTables, _
Array(Empty, Empty, Empty, "Table"))
Do While Not rs.EOF
List1.AddItem rs!TABLE_NAME
rs.MoveNext
Loop
rs.Close
oConn.Close
List1.ListIndex = 0
End Sub
Sub Load_Data(TableName As String)
Open_Connection
Set rsData = New ADODB.Recordset
SQL = "SELECT * FROM " & TableName
With rsData
.CursorLocation = adUseClient
.Open SQL, oConn, adOpenDynamic, adLockOptimistic
.ActiveConnection = Nothing
End With
Set DataGrid1.DataSource = rsData
oConn.Close
End Sub
Private Sub List1_Click()
Load_Data List1.Text
End Sub
Runtime:
Click here if you like this article.
8 Comments
klo mau migrasi data dari mysql nya biasanya bikin tool khusus buat export data nya.
Export data dalam bentuk yang bisa dibaca di banyak platform misalnya yang paling sederhana comma delimited simpan dalam bentuk file.
Nanti hasil file nya supaya bisa masuk ke access perlu tools lagi buat dibaca dan diinsert ke database access.
Jadi gini mba saya buat aplikasi ada fasilitas backup database, ketika restorenya bukan backup dari aplikasi yg saya buat tidak bisa teristore karena kalau terestore maka akan masuk tabel lain di database