C
Cowboy \(Gregory A. Beamer\)
I found an error in the Data Access application, specifically in the
tableMappings in the FillDataSet() overload with the following signature:
private static void FillDataset(SqlConnection connection, SqlTransaction
transaction,
CommandType commandType, string commandText, DataSet dataSet,
string[] tableNames, params SqlParameter[] commandParameters)
{
}
The code in question is line 1840 (C#), which reads:
tableName += (index + 1).ToString();
Assuming the following string:
string tableNames = {"MyTable1", "MyTable2", "MyTable3", "MyTable4" };
this original statement will produce:
dataAdapter.TableMappings.Add("Table" , "MyTable1");
dataAdapter.TableMappings.Add("Table1" , "MyTable2");
dataAdapter.TableMappings.Add("Table12" , "MyTable3");
dataAdapter.TableMappings.Add("Table123" , "MyTable4");
This is incorrect. It should be:
dataAdapter.TableMappings.Add("Table" , "MyTable1");
dataAdapter.TableMappings.Add("Table1" , "MyTable2");
dataAdapter.TableMappings.Add("Table2" , "MyTable3");
dataAdapter.TableMappings.Add("Table3" , "MyTable4");
FIX: The corrected version of this line (for reference: line 1840):
tableName = tableName + (index + 1).ToString();
NOTE that the VB.NET version is correct, with this string:
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
**********************************************************************
Think Outside the Box!
**********************************************************************
tableMappings in the FillDataSet() overload with the following signature:
private static void FillDataset(SqlConnection connection, SqlTransaction
transaction,
CommandType commandType, string commandText, DataSet dataSet,
string[] tableNames, params SqlParameter[] commandParameters)
{
}
The code in question is line 1840 (C#), which reads:
tableName += (index + 1).ToString();
Assuming the following string:
string tableNames = {"MyTable1", "MyTable2", "MyTable3", "MyTable4" };
this original statement will produce:
dataAdapter.TableMappings.Add("Table" , "MyTable1");
dataAdapter.TableMappings.Add("Table1" , "MyTable2");
dataAdapter.TableMappings.Add("Table12" , "MyTable3");
dataAdapter.TableMappings.Add("Table123" , "MyTable4");
This is incorrect. It should be:
dataAdapter.TableMappings.Add("Table" , "MyTable1");
dataAdapter.TableMappings.Add("Table1" , "MyTable2");
dataAdapter.TableMappings.Add("Table2" , "MyTable3");
dataAdapter.TableMappings.Add("Table3" , "MyTable4");
FIX: The corrected version of this line (for reference: line 1840):
tableName = tableName + (index + 1).ToString();
NOTE that the VB.NET version is correct, with this string:
tableName = tableName & (index + 1).ToString()
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
**********************************************************************
Think Outside the Box!
**********************************************************************