Saturday, May 28, 2011

LA4 AP2A (Database pada VB6.0) Tanggal 28 Mei 2011

Listing

Option Explicit
Dim Rs As New ADODB.Recordset

Private Sub Command1_Click()
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text1.SetFocus
End Sub

Private Sub Command3_Click()
With Rs
        .Delete
    End With
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text1.SetFocus
End Sub

Private Sub Command4_Click()
Unload Me
End Sub

Private Sub Form_Load()
    Dim Adodc1 As String

    'Koneksi database
    With Rs
        Adodc1 = App.Path & "\Database1.mdb"
        .ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Teknik Informatika\Latihan Pemrograman\VB 6.0\Data Base\Database1.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False"
      .CursorLocation = adUseClient
        .LockType = adLockOptimistic
       .CursorType = adOpenStatic
        .Source = "select * from Table1"
        .Open
    End With

    Set DataGrid1.DataSource = Rs
    DataGrid1.Refresh

End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set Rs = Nothing
End Sub
Private Sub Command2_Click()
With Rs
        .AddNew
        .Fields("nama").Value = Text1.Text
        .Fields("npm").Value = Text2.Text
        .Fields("kelas").Value = Text3.Text
        .Update
    End With
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text1.SetFocus
End Sub

Microsoft Access 2007



Design Form1 VB6.0

Adodc Properties





 


 Output


No comments:

Post a Comment