0

I am using a SQLDataReader to display the results of my stored procedure, however, I have been unable to have it display any records. I am not generating an error and if I write out reader.hasrows.tostring() it returns true so I know it is returning a single row as intended. I know I have data in all columns to display. Any guidance would be appreciated.

        Dim sqlcon2 As SqlConnection = New SqlConnection(Session("ConnStrEP"))
        sqlcon2.Open()

        Dim sqlcomm2 As SqlCommand = New SqlCommand("up_GetGenInfo_E1_01_02", sqlcon2)
        sqlcomm2.CommandType = Data.CommandType.StoredProcedure
        sqlcomm2.Parameters.Add("AppNo", AppNo)
        sqlcomm2.Parameters.Add("RevNo", RevNo)
        Dim dt As SqlDataReader = sqlcomm2.ExecuteReader()
        dt.Read()

        Response.Write(dt.Item("PrName").ToString())


        dt.Close()
        sqlcomm2.Dispose()
        sqlcon2.Close()

1 Answer 1

2

Do it in a following way:

 Do While dt.Read()
    Response.Write(dt.Item("PrName").ToString())
 Loop
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.