"Error in Line 4- System.NullReferenceException: 'Object reference not set to an instance of an object."
Private Sub btnsearch3_Click(sender As Object, e As EventArgs) Handles btnsearch3.Click
Dim vSearch As String = InputBox("Enter Employee Id to search the details:")
If vSearch <> "" Then
cmdSearch.CommandText = "SELECT * from Employee_Details WHERE Emp_Id =" & CInt(vSearch)
cmdSearch.Connection = cnnOLEDB
Dim rdrOLEDB As OleDbDataReader = cmdSearch.ExecuteReader
If rdrOLEDB.Read = True Then
txteid1.Text = rdrOLEDB.Item(0).ToString
txtepn2.Text = rdrOLEDB.Item(1).ToString
txtadd3.Text = rdrOLEDB.Item(2).ToString
txtphon4.Text = rdrOLEDB.Item(3).ToString
dtpdobirth5.Value = rdrOLEDB.Item(4).ToString
txtapt6.Text = rdrOLEDB.Item(5).ToString
dtpduty7.Value = rdrOLEDB.Item(6).ToString
dtpdoa8.Value = rdrOLEDB.Item(7).ToString
rdrOLEDB.Close()
MsgBox("Record found")
Exit Sub
Else
rdrOLEDB.Close()
MsgBox("Record not found")
Exit Sub
End If
Else
MsgBox("Enter search value.")
Exit Sub
End If
Jagruti22 0 Newbie Poster
Reverend Jim 4,968 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
xrjf 213 Posting Whiz
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.