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();
} }

|