Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.
Object, ByVal e
As [Link])
End Sub
Imports [Link]
Public Class Form1
Dim con As New OleDbConnection
Sub open_koneksi()
[Link] = "Provider=[Link].12.0" & _
";Data Source=[Link];"
[Link]()
End Sub
Sub data_load()
Dim cmd As New OleDbCommand
Dim adapt As New OleDbDataAdapter
Dim dt As New DataTable
Try
If Not [Link] = [Link] Then open_koneksi()
[Link] = con
[Link] = "select * from mhs"
[Link] = cmd
[Link](dt)
With DataGridView1
.AllowUserToAddRows = False
.ReadOnly = True
.DataSource = dt
End With
Catch ex As Exception
[Link]("data error")
Finally
[Link]()
End Try
End Sub
Sub data_load_tabel()
Dim cmd As New OleDbCommand
Dim adapt As New OleDbDataAdapter
Dim dt As New DataTable
Try
If Not [Link] = [Link] Then open_koneksi()
[Link] = con
[Link] = "select * from pddk"
[Link] = cmd
[Link](dt)
With DataGridView2
.AllowUserToAddRows = False
.ReadOnly = True
.DataSource = dt
End With
Catch ex As Exception
[Link]("Data Error")
Finally
[Link]()
End Try
End Sub
Private Sub Form1_Load(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
data_load()
data_load_tabel()
End Sub
Private Sub Button1_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim MyCommand As New OleDbCommand
Dim Sql As String
Try
If Not [Link] = [Link] Then open_koneksi()
If [Link] Then
' If CheckBox is checked, use INSERT INTO pddk query
Sql = "INSERT INTO pddk(nim, nm_mhs) VALUES " & _
"('" & [Link] & "', '" & [Link] & "')"
Else
' If CheckBox is not checked, use INSERT INTO mhs query
Sql = "INSERT INTO mhs(nim, nm_mhs) VALUES " & _
"('" & [Link] & "', '" & [Link] & "')"
End If
[Link] = con
[Link] = Sql
[Link]()
MsgBox("Data Berhasil diinput")
[Link] = [Link]
[Link] = [Link]
data_load()
[Link]()
Catch ex As Exception
MsgBox("Gagal")
End Try
[Link]()
End Sub
Private Sub Button2_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
If MsgBox("Yakin Akan Menghapus data ini ?", [Link], _
"Konfirmasi") = [Link] Then Exit Sub
Dim MyCommand As New OleDbCommand
Dim Sql As String
Try
If Not [Link] = [Link] Then open_koneksi()
Sql = "DELETE FROM mhs WHERE nim = " & _
"'" & [Link](1).Value & "'"
[Link] = con
[Link] = Sql
[Link]()
data_load()
[Link]()
Catch ex As Exception
[Link]("Error:")
Finally
[Link]()
End Try
End Sub
Private Sub Button3_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim mycommand As New OleDbCommand
Dim str As String
Try
If Not [Link] = [Link] Then open_koneksi()
str = "update mhs set nim = '" & [Link] & "', nm_mhs= '" &
[Link] & "' where nim = '" & [Link] & "'"
mycommand = New OleDbCommand(str, con)
[Link]()
data_load()
[Link]("data berhasil di update")
Catch ex As Exception
[Link]("data gagal di update")
End Try
End Sub
Private Sub CheckBox1_CheckedChanged_2(ByVal sender As [Link], ByVal e
As [Link])
If [Link] Then
[Link] = "mhs"
Else
[Link] = "pddk"
End If
End Sub