SQL PADA VISUAL BASIC FOR APPLICATION UNTUK MICROSOFT ACCESS
1. DOUBLE KLIK FORM
2. BUAT TOMBOL PADA FORM
3. KLIK KANAN PADA FORM TERSEBUT
4. KLIK CODE BUILDER
5. KEMUDIAN COPY KODE DI BAWAH INI
6. YANG PERTAMA ADALAH CREATE TABLE PEGAWAI YAITU UNTUK MEMBUAT TABEL PADA ACCESS
7. KE DUA MENGISI TABEL DENGAN INSERT INTO
8. DST COBA SENDIRI
Option Compare Database
Private Sub Command0_Click()
Dim dbs As Database
Set dbs = OpenDatabase("db11.mdb")
dbs.Execute "CREATE TABLE PEGAWAI " & "(NAMA CHAR, GAJI CHAR);"
dbs.Close
End Sub
Option Compare Database
Private Sub Command1_Click()
Dim dbs As Database
Set dbs = OpenDatabase("db11.mdb")
dbs.Execute "INSERT INTO PEGAWAI " & "(NAMA,GAJI) VALUES " & "('Harry', '4000000');"
dbs.Close
End Sub
Private Sub Command2_Click()
Dim dbs As Database
Set dbs = OpenDatabase("db11.mdb")
dbs.Execute "ALTER TABLE PEGAWAI " & "ADD COLUMN PAJAK CURRENCY;"
dbs.Close
End Sub
Option Compare Database
Private Sub Command0_Click()
Dim dbs As Database
Set dbs = OpenDatabase("db11.mdb")
dbs.Execute "ALTER TABLE PEGAWAI " & "DROP COLUMN PAJAK;"
dbs.Close
End Sub
Option Compare Database
Private Sub Command0_Click()
Dim dbs As Database
Set dbs = OpenDatabase("db11.mdb")
dbs.Execute "DELETE * FROM " & "PEGAWAI WHERE NAMA = 'Harry';"
dbs.Close
End Sub
Tidak ada komentar:
Posting Komentar