i have this code in my btnsave..it can detect conflicts but after that a dialog box saying:
An unhandled exception of type 'System.NullReferenceException' occurred in AppointmentSchedulingClient.exe

Additional information: Object reference not set to an instance of an object.

and it points to the green one below.

If Val(cbostart.Text) > Val(cboend.Text) Or Val(cbostart.Text) = Val(cboend.Text) Then
            MsgBox("Error in time.", MsgBoxStyle.Information, "MESSAGE")

            sqlsearch = "Select *from tblappointreserv"
            cmd2 = New OleDbCommand(sqlsearch, con2)
            dr = cmd2.ExecuteReader

         While dr.Read
                 Dim date, startime, endtime, d As String
              date = dtpdate.Text = dr("Whendate")
                startime = cbostart.Text = dr("Startime")
               endtime = cboend.Text = dr("Endtime")
                d = startime = True And endtime = True

                If d = True And date = True Then                   
                    MsgBox( "Sorry your appointment can't be reserve. Conflict has been detected.", MsgBoxStyle.Information, "MESSAGE")
                End If
                dr = Nothing
            End While
        End If

i still have the SQlInsert below that.. but this thing sucks me.. please help me..

Recommended Answers

are u initializing the dr? and check dr has rows to read.

Jump to Post

All 3 Replies

are u initializing the dr? and check dr has rows to read.

the dr has rows to read. i can say so, because when i click save it shows the msgbox..and the msgbox in inside the if condition which is under dr.read..

Wrap your code in a try/catch and like this:

'Your code here
catch ex as exception
end try

This will tell you what line your error is on.

Be a part of the DaniWeb community

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