Imports [Link].
MySqlClient
Public Class Form1
Sub ketemu()
Dim baca As MySqlDataReader
[Link] = kOn
[Link] = "SELECT * FROM tbl_mhs where nim ='" & [Link] & "'"
baca = [Link]()
Try
While [Link]
[Link] = [Link]("nm_mhs")
[Link] = [Link]("alamat")
[Link] = [Link]("ttl")
[Link] = [Link]("jk")
End While
Catch ex As Exception
End Try
[Link]()
End Sub
Sub kosong()
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link]()
End Sub
Sub cari()
Dim dt As New DataTable
[Link] = kOn
[Link] = "SELECT * FROM tbl_mhs where Nim ='" & [Link] & "'"
baca = [Link]()
' [Link]()
End Sub
Sub TampilDb()
Dim dt As New DataTable
Try
[Link] = kOn
[Link] = "SELECT * FROM tbl_mhs "
[Link] = cmd
[Link](dt)
[Link] = dt
With Tabel
.RowHeadersVisible = False
.AllowUserToAddRows = False
.ReadOnly = True
.Refresh()
End With
Catch ex As Exception
MsgBox("Terjadi Kesalahan", vbCritical, "Error")
Exit Sub
End Try
[Link]()
End Sub
Sub combo()
[Link]("Laki-Laki")
[Link]("Perempuan")
End Sub
Private Sub Form1_Load(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Bukadb()
TampilDb()
combo()
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As [Link], ByVal e As
[Link])
End Sub
Private Sub Button1_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
'Try
If [Link] = "" Then
MsgBox("Data Belum Lengkap")
Else
Bukadb()
Call cari()
End If
If Not [Link] Then
[Link]()
With cmd
.Connection = kOn
.CommandText = "Insert into tbl_mhs(nim,nm_mhs,alamat,ttl,jk) values " &
_
"('" & [Link] & "','" & [Link] & "','" &
[Link] & "','" & _
[Link] & "','" & [Link] & "' )"
.ExecuteNonQuery()
[Link]("Insert Data Mahasiswa Berhasil Dilakukan", "Pesan",
[Link])
kosong()
End With
Call TampilDb()
Else
[Link]()
[Link] = kOn
[Link] = "update tbl_mhs set " & _
"nm_mhs = '" & [Link] & "' ," & _
"alamat = '" & [Link] & "', " & _
"ttl = '" & [Link] & "', " & _
"jk = '" & [Link] & "' " & _
" where nim ='" & [Link] & "'"
[Link]()
[Link]("data sudah diubah", "Ubah Data",
[Link], [Link])
Call TampilDb()
kosong()
Exit Sub
End If
' Catch ex As Exception
'End Try
End Sub
Private Sub Button3_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
If [Link] <> "" Then
Dim Hapus = [Link]("Yakin Data " & [Link] & "Akan Dihapus ?",
"Hapus Data", [Link], [Link])
If Hapus = [Link] Then
[Link] = kOn
[Link] = "delete from tbl_mhs where nim ='" & [Link] &
"'"
[Link]()
TampilDb()
kosong()
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
kosong()
End Sub
Private Sub Button4_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link]()
End Sub
Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As [Link])
Handles [Link]
ketemu()
End Sub
End Class