asp.net - "Invalid attempt to read when no data is present" though record exists

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • divsTiw
    New Member
    • Jan 2007
    • 2

    asp.net - "Invalid attempt to read when no data is present" though record exists

    I want to populate combo box with data from OracleDataReade r
    , but "Invalid attempt to read when no data is present."

    is thrown.

    there are two rows returned , then too why such error.

    plzzz share ur knowledge to help me out with this probs.

    my code is as below,

    Code:
    Private Sub FillRoleDesc()
            Dim strrefNo, sql As String
            Dim dr1 As OracleDataReader
            'Dim strGCRNno As String
            Try
                If Trim(txtRefNo.Text) <> "" Then
                    strrefNo = Trim(txtRefNo.Text)
                    dr = funRefernece(strrefNo)
                    Do While dr.Read
                        '  dr.GetString(0)
    
                        strGCRNno = dr.Item("CD_REF_NO")
    
                    Loop
                End If
                dr1 = funAccList(strGCRNno)
                If dr1.HasRows Then  'here is get error "Invalid attempt to read when no data is present."
    
                   
    
                    ddlOtherRel.DataSource = dr1
                    ddlOtherRel.DataTextField = dr1(0)
                    ddlOtherRel.DataValueField = dr1(0)
                    ddlOtherRel.DataBind()
                    'ddlOtherRel.Items.Insert(0, New ListItem("Select", "0"))
                End If
            Catch ex As Exception
                lblError.Text = ex.Message
            End Try
        End Sub
  • divsTiw
    New Member
    • Jan 2007
    • 2

    #2
    If any of you hv solution to my problem ,plzz plzzzz reply me soon

    Comment

    • Purnima Yadav
      New Member
      • May 2007
      • 1

      #3
      hello,This is purnima.I have also came across this exception and i have found that you must have register your UserName in database.bye for now.

      Comment

      • mktita
        New Member
        • Mar 2008
        • 5

        #4
        solution for datareader :


        when read data from datareader

        check here like this me doing in c#;
        Code:
        dr.read();
        if(dr.hasrows == true) // i,e data is exist & check that ur writing correct columnname, like this dr["firstname"].tostring();, other wise u find error
        thanks mahendra, email : <email removed as per Signature Guidelines>
        Last edited by Curtis Rutland; Oct 13 '08, 04:34 PM. Reason: removing email address

        Comment

        Working...