John's Brain Dump

All the technical gyrations I go through to build software, so I don't forget them and others can benefit from them.

Receive Email Updates

Typed DataSet Woes (Auto-Increment Keys)

I use typed datasets in my .NET solutions quite a bit. Since most of the applications that I build have a lot of pull-data-modify-it-save-it-back processing, the dataset provides me with a simple way to get that job done.

Sometimes, though, the tool that converts XSD schemas into typed datasets will crap out, and the errors that it reports can be less than helpful. Consider this error, for example:

Custom tool error: Unable to convert input xml file content to a DataSet. Parent Columns and Child Columns don't have type-matching columns.

I had just added a bunch of new tables, keys and relationships to my schema. Naturally, I looked at the relationships that I added, to verify that all of my child columns had the same data types as their related parent columns. No dice, all of the column types lined up. When I simply removed the relationships that I had added, the error went away, but when I put them back in, the error reappeared.

After about an hour of removing, adding, and changing parts of the schema, I stumbled on the solution. One of my new relationships was referencing a column of type xs:unsignedByte, and I had the column set to auto-increment. Apparently, the dataset generator gets *very unhappy* when you do this. Since the parent table didn't really need to have an auto-incrementing key, I just removed the auto-increment property and everything compiled fine.

Unfortunately, I don't know yet exactly *why* using an auto-incrementing unsigned byte key in a relationship caused the thing to crap out, but if I discover anything, I'll post a follow-up.

For more information about using typed datasets, check out Roy Osherove's blog entry about them. I definitely learned a thing or two.

Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted: Dec 07 2005, 08:19 PM by John | with no comments
Filed under: ,
Leave a Comment

(required) 

(required) 

(optional)

(required)