Dear All,
I have search a lot of forum or blog for this problem and have yet come up with a solution.. Hope anyone can help me here... Thanks a lot!!
I am using Ms Visual Basic 2008 Express Edition (vb.net)
Here is my code:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim check As Integer
Dim cmdVisitor As New SqlCommand
Dim daVisitor As New SqlDataAdapter
Dim dsVisitor As New DataSet
If MsgBox("Are you sure to edit Visitor data with Username : " & txtUsername1.Text & " ?", MsgBoxStyle.OkCancel, "Edit confirm") = MsgBoxResult.Cancel Then
' do nothing
Else
Try
Nconn = GetNConnect()
Nconn.Open()
cmdVisitor = conn.CreateCommand
cmdVisitor.CommandText = "UPDATE ClientDatabase SET Status= '" & Trim(txtStatus.Text) & "' WHERE Username ='" & Trim(txtUsername1.Text) & "'"
check = cmdVisitor.ExecuteReader.RecordsAffected
If check > 0 Then
MsgBox("Visitor with Username " & Trim(txtUsername1.Text) & " succesfully to update", MsgBoxStyle.OkOnly, "Info update data Visitor ")
Else
MsgBox("Visitor with Username " & Trim(txtUsername1.Text) & " failure to update", MsgBoxStyle.OkOnly, "Info update data Visitor ")
End If
Refresh_Form()
conn.Close()
Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!")
End Try
End If
End Sub
(I can post my entire code for this form if needed)