zoukankan      html  css  js  c++  java
  • 新发现:微软提供的SqlHelper中FillDataset方法一个小Bug (转)

    FillDataset(SqlConnection connection, CommandType commandType,
     string commandText, DataSet dataSet, string[] tableNames)
    当调用此方法,并指定映射表名数组,对应参数tableNames
    若元素超过3个,即指定表名超过3个时,从第3个表名开始返回的将是系统默认的表名
    而非用户指定的表名(如,指定"header" "detail" "relation",第3个返回了Table2)

    此Bug原因在这里:
    private static void FillDataset(SqlConnection connection, SqlTransaction transaction, CommandType commandType,
       string commandText, DataSet dataSet, string[] tableNames,
       params SqlParameter[] commandParameters)
    {
    ...
    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(); //若超过3个表,则
         tableName会变成Table11,Table111,返回映射表名即为Table2,Table3了
         解决方法即在此句前面加“tableName = "Table";”即可
         }
    ...
    }


  • 相关阅读:
    verdi issues on license
    geci
    组合数据类型练习
    熟悉常用的Linux操作
    1.大数据概述
    c语言文法分析
    词法分析器#include<stdio.h> #include<string.h> #include<iostream.h> char prog[80],token[8]; char ch; int syn,p,m=0,n,row,sum=0; char *rwtab[6]={"begin","if","then","while","do","end"
    关于编译原理
    可变参数
    函数和指针
  • 原文地址:https://www.cnblogs.com/onekey/p/42992.html
Copyright © 2011-2022 走看看