Nasty bug in Data Access Block Ver. 2.0

My blog has moved.
You can view this post at the following address:
http://www.osherove.com/blog/2003/7/28/nasty-bug-in-data-access-block-ver-20.html
Published Monday, July 28, 2003 9:10 PM by RoyOsherove
Filed under:

Comments

Monday, July 28, 2003 5:10 PM by TrackBack

# ISerializable

ISerializable
Tuesday, July 29, 2003 12:50 PM by Jason

# re: Nasty bug in Data Access Block Ver. 2.0

Good overview. This bug is also described in detail on the GotDotNet workspace for Data Access. Anyone interested in discussing the DAAB is more than welcome to join.

Thanks

Jason
Thursday, July 31, 2003 9:17 AM by Mel Grubb II

# re: Nasty bug in Data Access Block Ver. 2.0

I would argue that the line should also be moved before the actual fill. As the code stands (after the modification above), the table names will be Table, Table1, Table2

The first table is not named consistently with the others. Moving the tablename concatenation before the fill would provide more consistent results:
tableName = "Table" & (index + 1).ToString()
dataAdapter.TableMappings.Add(tableName, tableNames(index))

This would result in Table1, Table2, Table3, which in my opinion is better. Others may disagree.
Monday, August 11, 2003 11:22 AM by Diego Gonzalez

# re: Nasty bug in Data Access Block Ver. 2.0

Hey i'm guilty for that bug... I have solved this one and there will be a new version of the DAAB which supports an abstract factory so you can use the same code to call different ADO.NET providers... it will be available on the workspace this week.

Your solution is not totally correct because the tables must be named Table, Table1, Table2, and so on. So the correct code is:
In C#:
<pre>
dataAdapter.TableMappings.Add(
tableName + (index == 0 ? "" : index.ToString()),
tableNames[index] );
</pre>

In VB.NET
<pre>
dataAdapter.TableMappings.Add(tableName + CType(IIf(index = 0, "", index.ToString()), String), tableNames(index))
</pre>
Tuesday, February 17, 2004 7:39 PM by TrackBack

# re: Microsoft Data Access Application Block BUG!