Selasa, 18 Agustus 2020

Vb6 Ms Access: Menampilkan Data Di Datagrid


Yuk lanjut VB6 Access nya, pastikan udah baca artikel sebelum nya yah. Biar paham dan nyambung.
Tabel yang akan kita gunakan berjulukan category dengan isi selaku berikut:

Kemudian kita atur UI sebagai berikut:

Berikut code yang kita buat:
Option Explicit
Dim oConn As New ADODB.Connection
 
Dim rsData As New ADODB.Recordset 
Dim strConn As String 
Dim SQL As String

Sub Open_Connection()
Set oConn = New ADODB.Connection
oConn.ConnectionString = strConn
oConn.Open
End Sub

Sub Load_Data()
On Error GoTo errHandler

Open_Connection
Set rsData = New ADODB.Recordset
SQL = "SELECT * FROM Category"
With rsData
    .CursorLocation = adUseClient
    .Open SQL, oConn, adOpenDynamic, adLockOptimistic
    .ActiveConnection = Nothing
End With
Set
grdData.DataSource = rsData
oConn.Close

Exit Sub
errHandler:
MsgBox Err.Number & ":" & Err.Description
End Sub

Private Sub
Form_Load()
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source=" & App.Path & "\latihan.mdb;" & _
          "Persist Security Info=False"
Load_Data
End Sub


Runtime:
Selanjutnya kita akan menciptakan filter data dengan keyword.

Click here if you like this article.



Sumber http://rani-irsan.blogspot.com


EmoticonEmoticon