Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#15 mFieldNames uninitialised in DataReader.GetOrdinal

closed
nobody
None
5
2004-10-22
2004-10-21
Robert Foster
No

In the GetOrdinal Function of DataReader (version
0.20), the mFieldNames array is sometimes uninitialised.

I've solved this in my copy by placing the line
EnsureInitialization();
before the iteration through the array.

I tested this 4 times in a row without changing any
code, and only once did it manage to initialise this
property properly. I haven't been able to tied down
the problem, Data is returned once this issue has been
taken care of, so it's not because of an empty dataset.

Discussion

  • Robert Foster
    Robert Foster
    2004-10-22

    Logged In: YES
    user_id=526041

    I've had to use EnsureInitialization() in a lot of other
    places as well (GetDouble and friends, isDBNull, etc).
    Maybe this method should be called elsewhere to make sure
    that all other calls don't fall over?

     
  • Logged In: YES
    user_id=1000441

    It would be great to have code snippet where it occurred.

     
  • Logged In: YES
    user_id=1000441

    Did you call Read() function of DataReader before calling
    GetOrdinal?

     
  • Robert Foster
    Robert Foster
    2004-10-22

    Logged In: YES
    user_id=526041

    Hmm. No. I missed that for some reason. My code is rife
    with this problem, it used to work without the Read(). Oh
    well, I've fixed up my code and it's working now, thanks :)

     
  • Robert Foster
    Robert Foster
    2004-10-22

    • status: open --> closed