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

SMK Telkom Malang Data Management

This Visual Basic code defines a form with text boxes and buttons to manage a student database using MySQL. The form loads with methods to clear text boxes, disable text boxes, and display data in a datagridview. Buttons call methods to add, edit, delete, and display records. Methods connect to the database, build SQL queries, execute queries, and populate or clear the text boxes and datagridview.

Uploaded by

Philipus Making
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)
83 views3 pages

SMK Telkom Malang Data Management

This Visual Basic code defines a form with text boxes and buttons to manage a student database using MySQL. The form loads with methods to clear text boxes, disable text boxes, and display data in a datagridview. Buttons call methods to add, edit, delete, and display records. Methods connect to the database, build SQL queries, execute queries, and populate or clear the text boxes and datagridview.

Uploaded by

Philipus Making
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

Imports [Link].

MySqlClient
Public Class Form1

Sub kosongkan_Data()
[Link] = ""
[Link] = ""
[Link] = ""

End Sub
Sub TextMati()
[Link] = False
[Link] = False
[Link] = False
End Sub
Sub TextHidup()
[Link] = True
[Link] = True
[Link] = True
End Sub

Sub tampilkan_Data()
da = New MySqlDataAdapter("SELECT * FROM mahasiswa ", conn)
ds = New DataSet
[Link]()
[Link](ds, "mahasiswa")
[Link] = ([Link]("mahasiswa"))
[Link](0).Width = 77
[Link](1).Width = 250
End Sub

Sub TampilGrid()
Call Koneksi()
da = New MySqlDataAdapter("select * From mahasiswa ", conn)
DS = New DataSet
[Link](ds, "mahasiswa")
[Link] = [Link]("mahasiswa")
[Link] = True
End Sub

Private Sub Form1_Load(sender As [Link], e As [Link]) Handles


[Link]
Call TextMati()
Call kosongkan_Data()
Call koneksi()
Call tampilkan_Data()

End Sub

Private Sub Button3_Click(sender As [Link], e As [Link]) Handles

[Link] ===============HAPUS
If [Link] = "" Then
MsgBox("Silahkan Pilih Data yang akan di hapus dengan Masukan NIM dan ENTER")
Else
If [Link]("Yakin akan dihapus..?", "", [Link]) =
[Link] Then
Call koneksi()
Dim hapus As String = "delete From mahasiswa where nim='" &
[Link] & "'"
cmd = New MySqlCommand(hapus, conn)
[Link]()
Call TampilGrid()
Call kosongkan_Data()
End If
End If

End Sub

Private Sub TextBox1_KeyPress(sender As Object, e As


[Link]) Handles [Link]
[Link] = 6
If [Link] = Chr(13) Then
Call koneksi()
cmd = New MySqlCommand("Select * From mahasiswa where NIM='" & [Link]
& "'", conn)
dr = [Link]
[Link]()
If Not [Link] Then
MsgBox("NIM Tidak Ada, Silahkan coba lagi!")
[Link]()
Else
[Link] = [Link]("nama")
[Link] = [Link]("alamat")
[Link]()
End If
End If

End Sub

Private Sub Button1_Click(sender As [Link], e As [Link]) Handles


[Link] ==========================TAMBAH
Call TextHidup()
Call kosongkan_Data()
[Link]()
End Sub

Private Sub Button5_Click(sender As [Link], e As [Link]) Handles


[Link]
If [Link] = "" Or [Link] = "" Or [Link] = "" Then
MsgBox("Silahkan Isi Semua Form")
Else
Call koneksi()
Dim simpan As String = "insert into mahasiswa values ('" & [Link] &
"','" & [Link] & "','" & [Link] & "')"
cmd = New MySqlCommand(simpan, conn)
[Link]()
MsgBox("Input data berhasil")
Call tampilkan_Data()
Call kosongkan_Data()
End If
End Sub

Private Sub Button6_Click(sender As [Link], e As [Link]) Handles


[Link] =================EDIT
Call koneksi()
Dim edit As String = "update mahasiswa set nama='" & [Link] & "',alamat='"
& [Link] & "' where nim='" & [Link] & "'"
cmd = New MySqlCommand(edit, conn)
[Link]()
MsgBox("Data Berhasil diUpdate")
Call TampilGrid()
Call kosongkan_Data()

End Sub

Private Sub Button4_Click(sender As [Link], e As [Link]) Handles


[Link] ========================TUTUP
[Link]()
End Sub
End Class

You might also like