您的位置:首页 > 移动开发

Microsoft.ApplicationBlocks.Data 中的问题

2005-01-07 17:35 477 查看
Microsoft.ApplicationBlocks.Data 中的SqlHelper类中有一个非常要命的问题。在使用SqlHelper.FillDataSet系列函数时,如果DataSet中包含的数据表多余2个,那只能给头两个数据表指定名称后面的就会变成Table3...n..。
查看其源代码:

//Add the table mappings specified by the user
if (tableNames != null && tableNames.Length > 0)
{
string tableName = "Table";
for (int index=0; index < tableNames.Length; index++)
{
if( tableNames[index] == null || tableNames[index].Length == 0 ) throw new ArgumentException( "The tableNames parameter must contain a list of tables, a value was provided as null or empty string.", "tableNames" );
dataAdapter.TableMappings.Add(tableName, tableNames[index]);
tableName += (index + 1).ToString(); //问题就在这里,从第2个表开始tableName不是以“table2...tableN“的方式递增,而是以“table12,table123,table1...n“的方式递增。写成这样的方式就好了
tableName = "Table" + (index + 1).ToString();

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: