Can't get access to row's OBJECTID

1527
4
08-23-2011 12:35 PM
DanielWalton
Occasional Contributor
I am trying to access to the OBJECTID field of a table as a primary key so I can apply edits. It so happens that OBJECTID is the only unique field in the table. But whenever I try to access the value of OBJECTID with GetOID() or GetInteger("OBJECTID") I get the error:

"The value type is incompatible with the field type."

I have attached the XML description of the table. The values of OBJECTID in my table range from 2 to 100. Any ideas what's wrong?
0 Kudos
4 Replies
DanielWalton
Occasional Contributor
The attachment didn't make it. Here's my second try.
0 Kudos
DanielWalton
Occasional Contributor
I can't say for sure, but I think that this issue manifests itself in another way when I do manage to get to table.Update(row), where I get the error:

"The table does not contain an OID Field."

Looking at the xml description and my data, the table clearly does contain an OID field. I have tried creating the feature class from scratch and re-importing the data, to no avail.

Also, it's worth noting that I am able to Update() the table if I do my edits using a single RowCollection. But If I recycle the initial RowCollection and use another one later in my code, I get the above error.

Any help would be very appreciated.
0 Kudos
LanceShipman
Esri Regular Contributor
The XML looks correct. Can you post a code fragment. The .NET Wrapper ExecutineSQL sample prints out the OBJECTID and is working locally.
0 Kudos
DanielWalton
Occasional Contributor
Lance,

Just to follow up, I found the problem. I was using a LINQ .Single() method to update a single row, and wasn't disposing my RowCollection. Somehow this was causing the Row object to become disassociated with the table it was selected from.
0 Kudos