Kasus Jelas :
Flowchart :
Listing Program :
Dim koneksi As ADODB.Connection
Dim query As String
Dim idold As String
Sub conn()
Set koneksi = New ADODB.Connection
koneksi.Open “Provider=MSDASQL.1;Persist Security Info=false;Data Source=konektorzulfa”
End Sub
Private Sub Command1_Click()
Dim jenis_kelamin As String
If Option1.Value = True Then
jenis_kelamin = “L”
Else
jenis_kelamin = “P”
End If
query = “INSERT INTO krwzulfa1ia10 (NIP, Nama, Alamat, Jenis_Kelamin, Status, Tunjangan, Gaji, No_HP) values (‘” & txt_NIP.Text & “‘, ‘” & txt_Nama.Text & “‘, ‘” & txt_Alamat.Text & “‘, ‘” & jenis_kelamin & “‘, ‘” & cmb_Status.Text & “‘, ‘” & txt_Tunjangan.Text & “‘, ‘” & txt_Gaji.Text & “‘, ‘” & txt_No_HP.Text & “‘)”
koneksi.Execute query
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub Command2_Click()
Dim jenis_kelamin As String
If Option1.Value = True Then
jenis_kelamin = “Laki-laki”
Else
jenis_kelamin = “Perempuan”
End If
query = “UPDATE krwzulfa1ia10 SET Nama = ‘” & txt_Nama.Text & “‘, Alamat = ‘” & txt_Alamat.Text & “‘, Jenis_Kelamin = ‘” & jenis_kelamin & “‘, Status = ‘” & cmb_Status.Text & “‘, Tunjangan = ‘” & txt_Tunjangan.Text & “‘, Gaji = ‘” & txt_Gaji.Text & “‘, No_HP = ‘” & txt_No_HP.Text & “‘ WHERE NIP = ‘” & idold & “‘”
koneksi.Execute query
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub Command3_Click()
query = “DELETE FROM krwzulfa1ia10 WHERE nip = ‘” & txt_NIP & “‘”
koneksi.Execute query
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub DataGrid1_Click()
txt_NIP.Enabled = False
txt_NIP.Text = Adodc1.Recordset.Fields(“NIP”)
txt_Nama.Text = Adodc1.Recordset.Fields(“Nama”)
txt_Alamat.Text = Adodc1.Recordset.Fields(“Alamat”)
txt_Tunjangan.Text = Adodc1.Recordset.Fields(“Tunjangan”)
txt_Gaji.Text = Adodc1.Recordset.Fields(“Gaji”)
txt_No_HP.Text = Adodc1.Recordset.Fields(“No_HP”)
idold = txt_NIP.Text
End Sub
Private Sub Form_Load()
Call conn
Adodc1.ConnectionString = koneksi
Adodc1.RecordSource = “krwzulfa1ia10”
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Form Design :
Output :