Please help i am getting error when try to read data yet there is data in the table colorsdata
Server Error in '/' Application.
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.
Using Cony As New SqlConnection(conString)
Cony.Open()
Using Comy As New SqlCommand("Select * from Colorsdata", Cony)
Using RDRy = Comy.ExecuteReader()
If RDRy.HasRows Then
Dim query As String = "UPDATE student SET House = @code,Stream = @code2 WHERE admno = @Id"
Dim constr As String = ConfigurationManager.ConnectionStrings("UNIFORMConnectionString").ConnectionString
Using contb As New SqlConnection(constr)
Dim command As New SqlCommand(query, contb)
command.Parameters.Add("@code", SqlDbType.NChar).Value = RDRy.Item("color").ToString()
command.Parameters.Add("@code2", SqlDbType.NVarChar).Value = streamr
command.Parameters.Add("@Id", SqlDbType.Int).Value = admno
Cony.Open()
command.ExecuteNonQuery()
Cony.Close()
End Using
End If
End Using
End Using
Exit Sub
End Using