0% found this document useful (0 votes)
6 views2 pages

Call TampilData

The document contains a Visual Basic code for managing a book database, allowing users to insert, update, and delete book records. It includes functions to establish a connection to an Access database, display data in a DataGridView, and handle button click events for data operations. The code ensures that all required fields are filled before saving data and provides feedback messages upon successful operations.

Uploaded by

zero123rex
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Call TampilData

The document contains a Visual Basic code for managing a book database, allowing users to insert, update, and delete book records. It includes functions to establish a connection to an Access database, display data in a DataGridView, and handle button click events for data operations. The code ensures that all required fields are filled before saving data and provides feedback messages upon successful operations.

Uploaded by

zero123rex
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Call TampilData()

End Sub

Sub TampilData()
Call Koneksi()
da = New OleDbDataAdapter("Select * from buku", Conn)
ds = New DataSet
[Link]()
[Link](ds, "buku")
[Link] = [Link]("buku")
End Sub

Private Sub Button1_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]

If [Link] = "" Or [Link] = "" Then


MsgBox("Silahkan isi semua data")
Else
Call Koneksi()

Dim simpan As String = "insert into buku values ('" &


[Link] & "','" &
[Link] & "','" &
[Link] & "','" &
[Link] & "','" &
[Link] & "','" &
[Link] & "','" &
[Link] & "')"

cmd = New OleDbCommand(simpan, Conn)


[Link]()

MsgBox("Data berhasil disimpan")


Call TampilData()
End If

End Sub

Private Sub Button2_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]

Call Koneksi()

Dim edit As String = "update buku set " &


"Judul='" & [Link] & "'," &
"Penerbit='" & [Link] & "'," &
"Tahun='" & [Link] & "'," &
"Stok='" & [Link] & "'," &
"kode_jenis='" & [Link] & "'," &
"sinopsis='" & [Link] & "' " &
"where Kode_buku='" & [Link] & "'"

cmd = New OleDbCommand(edit, Conn)


[Link]()

MsgBox("Data berhasil diubah")


Call TampilData()

End Sub

Private Sub Button3_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]

Call Koneksi()

Dim hapus As String = "delete from buku where Kode_buku='" &


[Link] & "'"

cmd = New OleDbCommand(hapus, Conn)


[Link]()

MsgBox("Data berhasil dihapus")


Call TampilData()

End Sub
End Class

Module haha
Public Conn As OleDbConnection
Public da As OleDbDataAdapter
Public ds As DataSet
Public cmd As OleDbCommand
Public rd As OleDbDataReader
Public Str As String

Public Sub Koneksi()


Str = "Provider=[Link].12.0;Data Source=" &
[Link] & "\[Link]"
Conn = New OleDbConnection(Str)
If [Link] = [Link] Then
[Link]()
End If
End Sub
End Module

You might also like