--> Skip to main content
Pelajar Koding

follow us

Vb6 Ms. Access: Menampilkan List Table Yang Ada Pada Database Access - Part 2

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 String Dim 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.
Sumber http://rani-irsan.blogspot.com

You Might Also Like:

Comment Policy: Silahkan tuliskan komentar Anda yang sesuai dengan topik postingan halaman ini. Komentar yang berisi tautan tidak akan ditampilkan sebelum disetujui.
Buka Komentar