troubleshooting Question

Creating a datareader Causes an error

Avatar of wayneray
waynerayFlag for United States of America asked on
.NET ProgrammingMicrosoft Development
7 Comments1 Solution310 ViewsLast Modified:
I am new to vb.net and having fun learning. My Drd variable is declared public in my module. When I run this code. I get the error, "Object reference not set to an instance of an object."

Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
        Dim fname As String = txtFName.Text
        Dim lname As String = txtLName.Text
        Dim odt As Date = dtNurse.Value
        Dim symp As String = lstSymptom.SelectedItem
        Dim observ As String = txtAction.Text

        CurrentRow = 0

        Cnn.Open()

        Dad = New OleDbDataAdapter("SELECT Student_UID FROM tblElemStudents where First_Name = '" & fname.Replace("'", "''") & _
                                   "' and Last_Name = '" & lname.Replace("'", "''") & "'", Cnn)

        Dad.Fill(Dst, "Student_UID")
       


        Drd = Cmd.ExecuteReader

Everything runs fine up to the last line of code above. What am I doing wrong?

Thanks in advance.
ASKER CERTIFIED SOLUTION
John (Yiannis) Toutountzoglou
Instructor Multiengine Pilot

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros