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)

>Object reference not set to an instance of an object.

Error says that the object variable has null/nothing in it. To avoid such a problem check/verify the existence of object using IsNothing() method.

Dim Ds as DataSet
 if IsNothing(ds) Then
     Ds=new DataSet()
 End IF

Please show us where (line number) you got this exception.

THX!!!!!!!!!!!!!!!!!!!!!!!!!!!!

>Object reference not set to an instance of an object.

Error says that the object variable has null/nothing in it. To avoid such a problem check/verify the existence of object using IsNothing() method.

Dim Ds as DataSet
 if IsNothing(ds) Then
     Ds=new DataSet()
 End IF

THX!!!!!!!!!!!!!

Please show us where (line number) you got this exception.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.