Yuk lanjut VB6 Access nya, pastikan udah baca artikel sebelum nya yah. Biar paham dan nyambung.
Tabel yang akan kita gunakan bernama category dengan isi sebagai 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 membuat filter data dengan keyword.
Click here if you like this article.
2 Comments