You are on page 1of 10

Dim conn As New ADODB.

Connection

Dim rs As New ADODB.Recordset

Public Sub koneksi()

conn.ConnectionString = "Driver={MySQL ODBC 5.1


Driver};SERVER=localhost;UID=root;DATABASE=database_perpustaaan;PORT=3306"

conn.Open

End Sub

Private Sub from_load()

Call koneksi

End Sub

Private Sub Command1_Click()

Form2.Show

End Sub

Private Sub Command2_Click()

Adodc1.Recordset.Delete

DataGrid1.Refresh

End Sub
Private Sub Command4_Click()

Call koneksi

Dim sql As String

a = InputBox("masukan kode buku")

rs.Open "SELECT * FROM buku WHERE kode_buku='" & a & "'", conn

If rs.EOF = True Then

MsgBox "data tidak ada"

Else

Form4.Show

Form4.Text1.Text = rs.Fields("kode_buku")

Form4.Text2.Text = rs.Fields("judul")

Form4.Text3.Text = rs.Fields("pengarang")

Form4.Text4.Text = rs.Fields("penerbit")

Form4.Text5.Text = rs.Fields("tahun")

End If

conn.Close

End Sub

Private Sub DataGrid1_DblClick()

Form3.Show

Form3.Text1.Text = DataGrid1.Columns(0)

Form3.Text2.Text = DataGrid1.Columns(1)

Form3.Text3.Text = DataGrid1.Columns(2)

Form3.Text4.Text = DataGrid1.Columns(3)

Form3.Text5.Text = DataGrid1.Columns(4)

End Sub
Klik add muncul

Dim conn As New ADODB.Connection

Dim rs As New ADODB.Recordset

Public Sub koneksi()

conn.ConnectionString = "Driver={MySQL ODBC 5.1


Driver};SERVER=localhost;UID=root;DATABASE=database_perpustaaan;PORT=3306"

conn.Open

End Sub

Private Sub anjai_Load()

Call koneksi

End Sub

Private Sub Command1_Click()

Call koneksi

Dim sql As String

rs.Open "select*from buku where kode_buku='" & Text1.Text & "'", conn

If Not rs.EOF = True Then

MsgBox "data sudah ada"

Else

sql = "INSERT INTO buku (kode_buku,judul,pengarang,penerbit,tahun) VALUE ('" & Text1.Text & "','" &
Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "')"

conn.Execute sql

End If
Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

conn.Close

Form1.Adodc1.Refresh

End Sub

KLIK DATAGRID MUNCUL FORM 3

Dim conn As New ADODB.Connection

Dim rs As New ADODB.Recordset

Public Sub koneksi()

conn.ConnectionString = "Driver={MySQL ODBC 5.1


Driver};SERVER=localhost;UID=root;DATABASE=database_perpustaaan;PORT=3306"

conn.Open

End Sub

Private Sub from_load()

Call koneksi
End Sub

Private Sub Command1_Click()

Call koneksi

Dim sql As String

sql = "UPDATE buku SET kode_buku='" & Text1.Text & "', judul='" & Text2.Text & "', pengarang='" &
Text3.Text & "', penerbit='" & Text4.Text & "', tahun='" & Text5.Text & "' where kode_buku ='" &
Text1.Text & "'"

conn.Execute sql

conn.Close

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Form1.Adodc1.Refresh

Unload Me

End Sub

Klik menu cari muncul form

Dim conn As New ADODB.Connection


Dim rs As New ADODB.Recordset

Public Sub koneksi()

conn.ConnectionString = "Driver={MySQL ODBC 5.1


Driver};SERVER=localhost;UID=root;DATABASE=database_perpustaaan;PORT=3306"

conn.Open

End Sub

Private Sub from_load()

Call koneksi

End Sub

Private Sub Command1_Click()

Call koneksi

Dim sql As String

sql = "UPDATE buku SET kode_buku='" & Text1.Text & "', judul='" & Text2.Text & "', pengarang='" &
Text3.Text & "', penerbit='" & Text4.Text & "', tahun='" & Text5.Text & "' where kode_buku ='" &
Text1.Text & "'"

conn.Execute sql

conn.Close

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Form1.Adodc1.Refresh

Unload Me

End Sub

Private Sub Command2_Click()

Call koneksi
Dim hapus As String

hapus = "DELETE FROM buku where kode_buku='" & Text1.Text & "'"

conn.Execute hapus

conn.Close

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Form1.Adodc1.Refresh

Unload Me

End Sub

PEMINJAMAN

Dim conn As New ADODB.Connection

Dim rs As New ADODB.Recordset

Dim rsl As New ADODB.Recordset

Public Sub koneksi()

conn.ConnectionString = "Driver={MySQL ODBC 5.1


Driver};SERVER=localhost;UID=root;DATABASE=database_perpustaaan;PORT=3306"
conn.Open

End Sub

Private Sub from_load()

Call koneksi

End Sub

Private Sub Command1_Click()

view_anggota.Show

End Sub

Private Sub Form_Load()

Text2.Enabled = False

Command2.Enabled = False

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Call koneksi

rs.Open "SELECT * FROM anggota WHERE kode_anggota='" & Text1.Text & "'", conn

If rs.EOF = False Then

Label4.Caption = rs.Fields("nama")

Label5.Caption = rs.Fields("kontak")

Adodc1.RecordSource = "SELECT buku.kode_buku, buku.judul, peminjaman.tanggal_pinjam FROM


peminjaman,buku WHERE peminjaman.kode_buku=buku.kode_buku and peminjaman.kode_anggota='"
& Text1.Text & "'"

Adodc1.Refresh

With Adodc1.Recordset

Adodc1.Refresh

End With

rsl.Open "select * from peminjaman where kode_anggota='" & Text1.Text & "' and status='1'", conn
If rsl.EOF = False Then

Text2.Enabled = False

Command2.Enabled = False

Else

Text2.Enabled = True

Command2.Enabled = True

End If

'conn.close

Else

MsgBox "anggota belum terdaftar"

Text1.Text = ""

End If

conn.Close

End If

End Sub

Dim conn As New ADODB.Connection

Dim rs As New ADODB.Recordset

Public Sub koneksi()

conn.ConnectionString = "Driver={MySQL ODBC 5.1


Driver};SERVER=localhost;UID=root;DATABASE=database_perpustaaan;PORT=3306"

conn.Open

End Sub
Private Sub from_load()

Call koneksi

End Sub

Private Sub Command1_Click()

Call koneksi

Dim sql As String

rs.Open "select * from login where username='" & Text1.Text & "' and password='" & Text2.Text & "'",
conn

If rs.EOF = False Then

menu_utama.Show

Else

MsgBox "username atau password yang anda masukan salah"

End If

Text1.Text = ""

Text2.Text = ""

conn.Close

End Sub

Private Sub Command2_Click()

Unload Me

End Sub

Private Sub Form_Load()

Text1.Text = ""

Text2.Text = ""

End Sub

You might also like