all groups > dotnet ado.net > october 2004 >
You're in the

dotnet ado.net

group:

Data Access Application Block bug



Data Access Application Block bug amidanr NO[at]SPAM yahoo.com
10/31/2004 5:19:07 AM
dotnet ado.net: We're using the above mentioned Application Block in our project, in
order to execute stored procedure (SQL-Server). One of the stored
procedures executes a list of simple "select" commands, e.g. select *
from tableX, select * from tableY etc.
I used a string array in order to name the tables that are selected
(TableMappings).

I used one of the SqlHelper.FillDataset() overloads to execute my
stored procedures, and to my surprise the table names were completely
mismatched. After a short debugging session, it turned out that the
code line :
tableName += (index + 1).ToString();
(line 1840, method signature: private static void
FillDataset(SqlConnection connection, SqlTransaction transaction,
CommandType commandType, string commandText, DataSet dataSet,
string[]tableNames, params SqlParameter[] commandParameters)
contains the bug. tableName starts as "Table", on the second pass
it'll be "Table1", and on the third pass it'll be "Table12"!!! when it
should be "Table3".
the code line should be something like:
tableName = "Table" + (index + 1).ToString();

This fixes the problem.

For your information,
Amidan Roth,
amidanr@log-on.com
RE: Data Access Application Block bug Cowboy (Gregory A. Beamer) - MVP
11/1/2004 6:26:01 AM
This one has been mulled around for quite some time. Without looking at the
code, I believe you are correct, as the code is something like:

da.TableMappings.Add(tableName, mappedName);

tableName = "Table" + (index+1).ToString();

index++;

If the increment is before the setting of the new tableName, it is simply
index.ToString().

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

[quoted text, click to view]
AddThis Social Bookmark Button