Archive for May, 2006

Troubles with the Data Mapping Application Block v1.x

May 25, 2006

Environment: DAAB + DMAB Jume 2005 release.

Error retrieving data for the DataSet FooDS with the CommandText of usr_select_foo_sp: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

THis has happended to me 3 times now and each time with a different cause. The first time it was a problem with the data – there was some garbage data in the table. The second time was a coding error that caused the same dataset to be filled twice in succession. the third and current occasion is due to a mismatch between the column names in my typed dataset and those returned by the stored proc.

The datatable in the typed dataset has columns Foo and Bar (say) and the stored proc returns columns nvc_foo and int_bar. When the DMAB (or DAAB) fills the dataset , it creates new columns "nvc_foo" and "int_bar" in the data table. These get populated correctly, generating a number of rows in my typed dataset. The Foo and Bar columns for those rows are not populated and and thus violate various constraints.

The solution is to map the columns in the stored proc rowset to the proper columns in the typed dataset. In ADO.NET this can be achieved by setting up ColumnMappings in the DataAdapter. The DAAB (Data Access Application Block) wraps up the DataAdapater and gets in the way of this. Searching for a solution to this led me to the DMAB (Data Mapping Application Block). It reduces even more the amount of code than needs to be written to move between typed datasets and the database. It doe snot however seem to provide any way for mapping columns so a column int_foo of type integer returned by a stored procedure will be mapped to a column of the same name in a typed dataset. There does not seem to be any way of modifying this without writing a lot of code that bypasses the DMAB.

I will check out the v2 version of the DAAB/DMAB which require .Net v2, though our production environment is on .Net 1.1 and an upgrade is some time away.

Hello world!

May 24, 2006

Welcome to This is your first post. Edit or delete it and start blogging!