0% found this document useful (0 votes)
65 views3 pages

Hapus Database MySQL dengan VB 2010

This VB.NET code connects to a MySQL database to perform CRUD operations on a member/user table. It opens a connection to the database, displays existing members in a datagrid, allows adding/editing members by populating textboxes from a selected member, and deletes a member by their ID number by executing a DELETE query after user confirmation. The code handles validation, updating the UI, and closing the database connection.

Uploaded by

Egi Ginanjar
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)
65 views3 pages

Hapus Database MySQL dengan VB 2010

This VB.NET code connects to a MySQL database to perform CRUD operations on a member/user table. It opens a connection to the database, displays existing members in a datagrid, allows adding/editing members by populating textboxes from a selected member, and deletes a member by their ID number by executing a DELETE query after user confirmation. The code handles validation, updating the UI, and closing the database connection.

Uploaded by

Egi Ginanjar
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

Hapus Database MySQL VB 2010

Imports [Link]
Public Class Form1
Dim Conn As OdbcConnection
Dim da As OdbcDataAdapter
Dim ds As DataSet
Dim str As String
Dim CMD As OdbcCommand
Dim RD As OdbcDataReader

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


[Link]) Handles [Link]
Call KondisiAwal()
End Sub
Sub Koneksi()
str = "Driver={MySQL ODBC 5.3 ANSI
Driver};database=DBperpustakaan;server=localhost;uid=root"
Conn = New OdbcConnection(str)
If [Link] = [Link] Then
[Link]()
End If
End Sub

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


[Link]) Handles [Link]
If [Link] = "" Or [Link] = "" Or [Link] = "" Or
[Link] = "" Then
MsgBox("Data belum lengkap, Pastikan Nomor anggota 6 Digit dan Semua
form terisi")
Exit Sub
Else
Call Koneksi()

If [Link]("Yakin akan dihapus..?", "",


[Link]) = [Link] Then
Dim hapus As String = "DELETE FROM anggota WHERE [Link]
= '" & [Link] & "'"
CMD = New OdbcCommand(hapus, Conn)
[Link]()
MsgBox("Data berhasil di Hapus", [Link],
"Information")
Call KondisiAwal()
End If
End If
End Sub
Sub KondisiAwal()
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
Koneksi()
da = New OdbcDataAdapter("Select * from anggota", Conn)
ds = New DataSet
[Link]()
[Link](ds, "anggota")
[Link] = ([Link]("anggota"))
End Sub

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As


[Link]) Handles [Link]
If [Link] = Chr(13) Then
Call Koneksi()
CMD = New OdbcCommand("Select * from anggota where nomoragt='" &
[Link] & "'", Conn)
RD = [Link]
[Link]()

If Not [Link] Then


[Link] = ""
[Link] = ""
[Link] = ""
[Link]()
Else
[Link] = [Link]("Namaagt")
[Link] = [Link]("alamatagt")
[Link] = [Link]("teleponagt")
[Link]()
End If
End If
End Sub
End Class

You might also like