Enjoy Every Sandwich

Thoughts on SQL, XML, .NET and sometimes beer.

<October 2008>
SuMoTuWeThFrSa
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678


Navigation

Tools

List O'Links

Kent's Other Stuff

Subscriptions

News

Please read these
Notices and Disclamiers

Post Categories

Article Categories



Monday, August 21, 2006 - Posts

Autoincrement Bytes.

I was happily coding up an example where I have a ADO.NET 1.x DataTable that's has an auto-incrementing field. Being the conservative type I am, I had coded the two fields to be of type Byte. When trying to create the ForeignKeyConstraint related to that column, I got an exception:

Property not accessible because 'Parent Columns and Child Columns don't have type-matching columns.'.

Sure enough, if you go check the DataType of the auto-incrementing column, its been "upgraded" to System.Int32. Silently. Nice. Now that you know the problem, the fix is easy. Make the columns Int32's. Ick.

Leason learned after 20 minutes of chasing that one down. Its going to be a grrrreeeaaat week.

posted Monday, August 21, 2006 12:35 PM by ktegels




Powered by Dot Net Junkies, by Telligent Systems