How can I solve this error:
Invalid attempt to read when no data is present.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.InvalidO perationExcepti on: Invalid attempt to read
when no data is present.
Source Error:
Line 42: Dim rs As SqlDataReader = sqlCmd.ExecuteR eader()
Line 43: rs.Read()
Line 44: Response.Write( rs("Nombre"))
Line 45: Response.End()
Line 46: %>
This is my code:
Dim sqlConn As SqlConnection
Dim sqlCmd As SqlCommand
Dim strConnection, resul As String
strConnection =
ConfigurationMa nager.Connectio nStrings("SIPco nnectionstring" ).ConnectionStr ing
sqlConn = New SqlConnection(s trConnection)
sqlCmd = New SqlCommand("Sel ect * from documentos where
idpropuesta='" & Request.QuerySt ring("mivar") & "'", sqlConn)
sqlConn.Open()
resul = sqlCmd.ExecuteN onQuery
Dim rs As SqlDataReader = sqlCmd.ExecuteR eader()
rs.Read()
Response.Write( rs("Nombre"))