You are on page 1of 1

Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.

E
ventArgs) Handles btnEdit.Click
con.Open()
SqlString = "update TableMHS set Nama ='" & txtNama.Text & "', IP = '"
& txtIP .Text & "', Jurusa = '" & txtJrsn.Text & "', Prodi = '" & txtProdi.Text
& "'where NIM = '" & txtNIM.Text & "'"
nummaffected = cmd.ExecuteNonQuery
If (nummaffected > 0) Then
MessageBox.Show("Data Terupdate")
Call kosongkan()
End If
End Sub
Sub kosongkan()
txtNIM.Clear()
txtNama.Clear()
txtIP .Clear()
txtJrsn.Clear()
txtProdi.Clear()
End Sub
Private Sub txtNIM_ eyPress(ByVal sender As Object, ByVal e As System.Window
s.Forms. eyPressEventArgs) Handles txtNIM. eyPress
Dim cek As Double
Dim cmd1 As SqlCommand
If e. eyChar = vbCr Then
con.Open()
SqlString = "selesct * from TableMHS wehere NIM='" & txtNIM.Text & "
'"
cmd1 = New SqlCommand(SqlString, con)
cek = cmd1.ExecuteScalar()
If cek > 0 Then
cmd = New SqlCommand(SqlString, con)
reader = cmd.ExecuteReader()
While reader.Read()
txtNama.Text = reader("Nama")
txtIP .Text = reader("IP ")
txtJrsn.Text = reader("Jurusan")
txtProdi.Text = reader("Prodi")
End While
End If
txtNama.Focus()
End If
con.Close()
End Sub

You might also like