Reputation: 891
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()
Upvotes: 0
Views: 1268
Reputation: 2570
Do it in a following way:
Do While dt.Read()
Response.Write(dt.Item("PrName").ToString())
Loop
Upvotes: 2