E
egsdar
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.InvalidOperationException: Invalid attempt to read
when no data is present.
Source Error:
Line 42: Dim rs As SqlDataReader = sqlCmd.ExecuteReader()
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 =
ConfigurationManager.ConnectionStrings("SIPconnectionstring").ConnectionString
sqlConn = New SqlConnection(strConnection)
sqlCmd = New SqlCommand("Select * from documentos where
idpropuesta='" & Request.QueryString("mivar") & "'", sqlConn)
sqlConn.Open()
resul = sqlCmd.ExecuteNonQuery
Dim rs As SqlDataReader = sqlCmd.ExecuteReader()
rs.Read()
Response.Write(rs("Nombre"))
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.InvalidOperationException: Invalid attempt to read
when no data is present.
Source Error:
Line 42: Dim rs As SqlDataReader = sqlCmd.ExecuteReader()
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 =
ConfigurationManager.ConnectionStrings("SIPconnectionstring").ConnectionString
sqlConn = New SqlConnection(strConnection)
sqlCmd = New SqlCommand("Select * from documentos where
idpropuesta='" & Request.QueryString("mivar") & "'", sqlConn)
sqlConn.Open()
resul = sqlCmd.ExecuteNonQuery
Dim rs As SqlDataReader = sqlCmd.ExecuteReader()
rs.Read()
Response.Write(rs("Nombre"))