public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");            // Create & open a SqlConnection, and dispose of it after we are done
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();                // Call the overload that takes a connection in place of the connection string
                return ExecuteDataset(connection, commandType, commandText, commandParameters);
            }
        }
上面的代码是MS的sqlHelper,我用了之后发现网站经常出现列xxx不属于表table的错误
不知道是不是上面的方法的错误,急急急,现在网站正在搞活的

解决方案 »

  1.   

    列xxx不属于表table的错误 
    这个也不是关没关连接的错啊!
      

  2.   

    那是什么错误啊网站人数多的时候就会这样
    总数列 XX不属于表table而且调试没有问题,压力测试就会有问题
      

  3.   

    SqlConnection实现了dispose接口 using大括号结束会自动释放资源的
      

  4.   

    我觉得不是close的问题
    但是就是找不到原因,请各位帮帮忙
      

  5.   

    sql绝对没有错,因为本地测试都没有错的,而且不是每次会这样错误的
    using语句结束会调用connection的dispose()方法的现在网站一直错误啊,还是找不到原因急急急啊
      

  6.   

    总数列 XX不属于表table
    ==
    可能是你传的commandParameters多了,table里没有那个列,你查查sql语句
      

  7.   

    sql语句没有错啊,有错的话那每次都错,问题是我的项目本地都没有错我搜索了下,有人说是datagrid什么列宽的错误,好像我项目又没有用这个控件
    现在还是没有找到什么错误
      

  8.   

    你把断点放在return ExecuteDataset(connection, commandType, commandText, commandParameters);这条语句上,看看commandType, commandText, commandParameters,这几个参数,看看传进去的列和目标表中
    列是不是一一匹配的
      

  9.   

    难道是sql语句没有优化????
      

  10.   

    sql语句应该有问题
    语句中的某一字段不是所查询表中的字段
      

  11.   

    贴出这个核心代码,让大家看看return ExecuteDataset(connection, commandType, commandText, commandParameters);
      

  12.   


    public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
            {
                if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");            // Create & open a SqlConnection, and dispose of it after we are done
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();                // Call the overload that takes a connection in place of the connection string
                    return ExecuteDataset(connection, commandType, commandText, commandParameters);
                }
            }
      

  13.   

    贴出这个函数的最底层函数的代码,看来这个ExecuteDataset重载的比较多,要最底层的
    // Call the overload that takes a connection in place of the connection string
                    return ExecuteDataset(connection, commandType, commandText, commandParameters);
      

  14.   

    有时候是没有清除参数所致
    cmd.Parameters.Clear();