none
InvalidOperationException: Operation is not valid due to the current state of the object

    Question

  • Hi,

    Please help us with the following issue while displaying the data of a oracle data reader - 2 reference cursors set output from a oracle stored procedure.

     

    ODP.NET - Error while using a field

            If (objRsA.NextResult()) Then 'Success means next result set is there
                If objRsA.HasRows Then 'Next result set has rows
     
                    Do While objRsA.Read() ' read true means it has data and connection is open

                        If objRsA.IsDBNull(objRsA("name")) Then - ERRORRRRRRRRRRRRRRRR
                            curContName = " Null "
                        End If
                       
                    loop
                 end if
             end if
            
    - System.InvalidOperationException: Operation is not valid due to the current state of the object.


    [InvalidOperationException: Operation is not valid due to the current state of the object.]
       Oracle.DataAccess.Client.OracleDataReader.IsDBNull(Int32 i) +221
       Oracle.DataAccess.Client.OracleDataReader.GetValue(Int32 i) +277
       Oracle.DataAccess.Client.OracleDataReader.get_Item(Int32 i) +39
       Oracle.DataAccess.Client.OracleDataReader.get_Item(String columnName) +59

     

    Is there any solution for this or alternate method? Thanks.

    • Moved by Kee Poppy Tuesday, February 15, 2011 2:42 AM (From:Visual Basic IDE)
    Monday, February 07, 2011 8:00 PM

All replies

  • Hi srini,

    From the error message can tell that IsDBNull() should receive Interger as its parameter. So, what is the return data type of objRsA("name")? Is it Interger? On the other hand, I think you will probably get more efficient responses if you post it in Oracle forum.

     

    Best Regards,


    Kee Poppy [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 09, 2011 9:27 AM
  • The return value is string. I am just checking the null value or trying to display the value.

    If objRsA.IsDBNull(objRsA("name")) Then

    OR

    If IsDBNull(objRsA("name")) Then

    Alternate

    temp1 = objRsA("name")

    The Oracle compiler may trying to match the field name with field number(int). Even if it has type mismatch issue, the error message should indicate that. But it is giving error message about the state of the record set. The same code is working for other pages, there we have 5 ref cursors. Sure, I am trying at other forum also.

    Wednesday, February 09, 2011 12:55 PM
  • We got the solution. As of now we are using 10g provider and now we installed 11g provider and it worked fine. We didn't change any code. So assuming that it might be a bug in 10g and fixed it in 11g. Thanks again for your help.
    • Proposed as answer by srini3213 Tuesday, February 15, 2011 4:45 PM
    Tuesday, February 15, 2011 4:45 PM