Public member 'ExecuteReader' on type 'SqlDataAdapter' not found

I get this error:

Public member 'ExecuteReader' on type 'SqlDataAdapter' not found.

When it tries to run my code below:

        objConn.Open()

        Dim da = New SqlDataAdapter("My_test", objConn)
        da.SelectCommand.CommandType = CommandType.StoredProcedure

        Dim reader As SqlDataReader = da.ExecuteReader() <-------------- error is here

        'Read in the first record and grab the first column
        Dim prowcount As Integer
        If reader.Read() Then
            prowcount = Convert.ToInt16(reader("@@ROWCOUNT"))
        Else
            prowcount = 0
        End If

        MsgBox(prowcount)

        objConn.Close()
LVL 1
dba123Asked:
Who is Participating?
 
razorback041Commented:
try this...the da uses the .fill method not the reader

Dim cmdSql as new sqlClient.SqlCommand(SP Name here, objConn)
Dim Reader  As SqlDataReader

objConn.Open()
reader = cmdsql.ExecuteReader\

 Dim prowcount As Integer
        If reader.Read() Then
            prowcount = Convert.ToInt16(reader("@@ROWCOUNT"))
        Else
            prowcount = 0
        End If

        MsgBox(prowcount)

        objConn.Close()
0
 
dba123Author Commented:
thanks much! worked
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.