Issue for ODBCDataReader RRS feed

  • Question

  • Hi Guys,

      I am currently experiencing a issue of ODBCDataReader.

    I call a stored procedure to return a row(only one row) with 61 fields.

    Here is the code segment as below:


    Dim objRec As Odbc.OdbcDataReader

    objRec = cmd.ExecuteReader(CommandBehavior.SingleRow)

    If(objRec.HasRows = True andAlso objRec.Read()) Then

    Dim a as String = objRec("Cmpy_Code")

    Dim b as String = objRec("Ordr_Noxx")


    End If


    Sometimes, I got exception at 'Dim a as String = objRec("Cmpy_Code")'


    The error message is :Object reference not set to an instance of an object.


    This situation doesn't happen all the time. If I try it on a fast machine, it is ok. It only happened on a slow machine so far.


    So, I wonder if the ODBC DataReader got the rows description(like number of rows returned) first, the objRec.HasRows is set to True, but it doesn't receive the columns information, at this point, the system is starting to read objRec("Cmpy_Code"). So I got the exception.


    Please be advised


    Thanks in advance



    Thursday, August 30, 2007 8:16 PM