Event code: 3005 
Event message: 发生了未处理的异常。 
Event time: 2013-6-24 18:00:22 
Event time (UTC): 2013-6-24 10:00:22 
Event ID: cbfa2f7bc4eb47a68497fbb0a29fe624 
Event sequence: 36 
Event occurrence: 1 
Event detail code: 0 
 
Application information: 
    Application domain: /LM/W3SVC/87716255/Root-1-130165414721845000 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: D:\wwwroot\******\ 
    Machine name: ****** 
 
Process information: 
    Process ID: 4872 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 
 
Exception information: 
    Exception type: Exception 
    Exception message: 已有打开的与此命令相关联的 DataReader,必须首先将它关闭。 
 
Request information: 
    Request URL: http://******/index.aspx 
    Request path: /index.aspx 
    User host address: 125.77.78.54 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
 
Thread information: 
    Thread ID: 8 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
    Is impersonating: False 
    Stack trace:    在 Common.DB.dataSet(String sqlstr) 位置 D:\******\******\******\******\Common\DB.cs:行号 367
   在 newpage.dlFriendBind() 位置 d:\wwwroot\******\Index.aspx.cs:行号 25
   在 newpage.Page_Load(Object sender, EventArgs e) 位置 d:\wwwroot\******\Index.aspx.cs:行号 17
   在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   在 System.Web.UI.Control.OnLoad(EventArgs e)
   在 System.Web.UI.Control.LoadRecursive()
   在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 
 
Custom event details: 有关更多信息,请参阅在 http://go.microsoft.com/fwlink/events.asp 的帮助和支持中心。
我想问下 这个是数据库连接问题 还是代码问题  本人C#新手 刚刚接手公司以前技术做的网站

解决方案 »

  1.   

    DataReader 使用后,要关闭,是连接数据库访问模式dr.Close();不然后就采用断开式访问 利用适配器填充数据到dataset
      

  2.   

    DataReader 没有关闭,如果你用的是传统的dbhelper类的话,你需要修改那个类,每次返回对象的时候要判断DataReader是否打开,如果DataReader还没执行完,你就new一个出来
      

  3.   

    DataReader打开用完了要及时关闭,
    要么两个DataReader用不同的SqlConnection
      

  4.   

            public static DataSet dataSet(string sqlstr)
            {
                DataSet ds = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter();
                try
                {
                    openConnection();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = sqlstr;
                    da.SelectCommand = cmd;
                    da.Fill(ds);
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
                finally
                {
                    closeConnection();
                }
                return ds;
            }这个是DB 文件 367是throw new Exception(e.Message); 这行 是不是写的有问题?
      

  5.   

    使用SqlDataAdapter时没有必要从Connection.open()打开,SqlDataAdapter会自动打开关闭它。
    给个例子string strConn="uid=账号;pwd=密码;database=数据库;server=服务器";//SQL Server链接字符串
    SqlConnection ConnSql=new SqlConnection (strConn); //Sql链接类的实例化
    string strSQL="SELECT * FROM 表名1 "; //要执行的SQL语句
    SqlDataAdapter da=new SqlDataAdapter(strSQL,ConnSql); //创建DataAdapter数据适配器实例
    DataSet ds=new DataSet();//创建DataSet实例
    da.Fill(ds,"自定义虚拟表名");//使用DataAdapter的Fill方法(填充),调用SELECT命令
      

  6.   

        Exception message: 已有打开的与此命令相关联的 DataReader,必须首先将它关闭。
      

  7.   

    [yabao=][/yabao]维护代码神马的最惨了