不是缓存cmd确实是静态的怎么定义好

解决方案 »

  1.   

    表中不存在A、b、c列,你是不是没有表头就插入行了!
      

  2.   

    已经把cmd定义到方法里了,刚才没看懂你说的意思,又看一遍知道了,
    我先测试下 #region 执行带参数的sql语句或存储过程,返回一个DataTable对象
            /// <summary>   
            /// 执行带参数的sql语句或存储过程,返回一个DataTable对象   
            /// </summary>   
            /// <param name="cmdText">sql语句或存储过程名</param>   
            /// <param name="cmdType">命令类型</param>   
            /// <param name="cmdParms">参数集合</param>   
            /// <returns>返回一个DataTable对象</returns>   
            public static DataTable GetDataTable(string cmdText, CommandType cmdType, SqlParameter[] cmdParms)
            {
                SqlDataReader reader;
                DataTable dt = new DataTable();
                try
                {
                    init();
                    SqlCommand cmd = new SqlCommand();
                    SetCommand(cmd, cmdText, cmdType, cmdParms);
                    reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                    dt.Load(reader);
                    reader.Close();
                   // conn.Close();//---
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message.ToString());
                }
                return dt;
            }
            #endregion
      

  3.   

    服务器20003的和插入a,b,c列没关系时好时坏,人少的时候正常人一多服务器页面报错乱七八糟,当前页面都没写这sql语句,都能显示出来那sql语句是别的页面上的,怎么会出现这个页面。估计是并发问题,同时操作反映不过来。。方法我都试试,不止我一个人出现这个情况,很多人都是这样,我就郁闷别人怎么解决服务器上这种问题的
      

  4.   

    不行啊,把静态cmd变量 放到方法一样,狂刷又出现了
    Server Error in '/' Application.
    --------------------------------------------------------------------------------DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'type'. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'type'.Source Error: 
    Line 105:                                    <tr>
    Line 106:                                        <td style="text-align: left">
    Line 107:                                            <%#Eval("type")%>
    Line 108:                                            <a href="WriteInfo.aspx?id=<%#Eval("id")%>" target="_blank" title="<%#Eval("title")%>">
    Line 109:                                                <%#Eval("title") %></a>
     
      

  5.   

    已经去掉了啊  // public static SqlCommand cmd = null;
            public static SqlConnection conn = null;
            public static string connstr = Maticsoft.DBUtility.PubConstant.GetConnectionString("connstr");
      

  6.   

    conn也不要用静态的,用using确保每次数据库连接完关闭连接并销毁资源就可以了