在本地可以完全运行,但传到服务器上后,到后台操作一段时间就会报错,有时好有时坏,
已下错误信息:: Server Error in '/' Application. 
-------------------------------------------------------------------------------- 未指定的错误 
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.Exception: 未指定的错误 Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  Stack Trace: 
[Exception: 未指定的错误] 
  DbHelperSQL.GetSingle(String SQLString) +229 
  DbHelperSQL.Exists(String strSql) +5 
  login.ImgButLogin_Click(Object sender, ImageClickEventArgs e) +269 
  System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +86 
  System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115 
  System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 
  System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 
  System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 
  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746 public class DbHelperSQL 

      
  
      protected static string connectionString ="Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + HttpContext.Current.Server.MapPath("~") + "\\" + System.Web.Configuration.WebConfigurationManager.AppSettings["DataPath"]; 
        public DbHelperSQL() 
        { 
        } public static int ExecuteSql(string SQLString) 
        { 
            using (OleDbConnection connection = new OleDbConnection(connectionString)) 
            { 
                using (OleDbCommand cmd = new OleDbCommand(SQLString, connection)) 
                { 
                    try 
                    { 
                        connection.Open(); 
                        int rows = cmd.ExecuteNonQuery(); 
                        return rows; 
                    } 
                    catch (System.Data.OleDb.OleDbException E) 
                    { 
                        connection.Close(); 
                        throw new Exception(E.Message); 
                    } 
                } 
            } 
        } 
  //等...其它通用的一些方法,全是静态的
}

解决方案 »

  1.   

    我感觉应该是传进来的sql语句的问题,从这方面查查吧,这个函数应该是好的
      

  2.   

    应该是执行的SQL语句有些问题,是不是没有对提交的数据做细致的验证?
      

  3.   

    先别急着调试,你说的时好时坏,其实是不好提示的
    你先看看你的系统日志,有没有什么错误,类似于:
    系统日志具体描述如下: DCOM 错误 无 10010 NT AUTHORITY\SYSTEM Myserver 服务器 {3D14228D-FBE1-11D0-995D-00C04FD919C1} 没有在限定的时间内用 DCOM 注册。 W3SVC 警告 无 36 N/A Myserver 服务器未能转入应用程序 '/LM/W3SVC/1/Root'。错误是 '服务器运行失败 '。 
    若要获取关于此消息的更多的信息,请访问 Microsoft 联机支持站点: http://www.microsoft.com/contentredirect.asp 。 应用程序日志具体描述如下: COM+ 错误 管理 4205 N/A Myserver 由于在下列系统 API 错误,COM+ 服务无法初始化。它通常是由本地计算机的系统资源存储问题引起的。 
    CryptAcquireContext 
    进程名称: dllhost.exe 
    该错误的严重性已导致进程终止。 
    错误代码= 0x80090017 : 提供程序类型未被定义。 
    COM+ 服务内部信息: 
    文件: .\security.cpp, 行: 617 
      

  4.   

    有的话,你把与web有关的类似于 IUSR_和IWAM_的密码改下,然后在iis里做一次同步修改看看!
      

  5.   

    实在不行的话,告诉你一个最简单的方法就是重新把iis装一次一般都可以解决问题(当然要重新注册下.net framwork)
      

  6.   

    是不是sql语句中包括特殊字符,
    建议使用try_catch获取具体的出错位置与信息。
      

  7.   

    你可以把SQL在数据库中执行以下看看看你的SQL有问题么
      

  8.   


    要根据异常的堆栈信息来找问题,就好像你给出public static int ExecuteSql(string SQLString) 方法,你想说明跟堆栈信息又有什么关系呢?通常你可以在login.ImgButLogin_Click(Object sender, ImageClickEventArgs e) +269 这里设置一个日志(比如只是一个简单的文本文件),将调用 DbHelperSQL.Exists(String strSql) 时使用的strSql记录下来,这样你就可以在发现bug时看出最后的sql语句是什么。然后贴出这个sql来。
    质量好的系统,应该经过自动化测试,而不是手工测试。如果程序上线前一有空闲时间就使用自动化测试,那么上线时已经曾经从数据库中随机生成100万次测试数据,这类bug很可能早已经不经意间早已经解决了(甚至不觉得花了什么时间)。手工测试只能发现少量问题,而大量使用了一段时间才偶尔发生的问题则仍然会浪费你大量时间,而且这些问题都是发生在上线之后造成的损失其实是很大的。
      

  9.   

    我的意思是说,“调试时没出有错”这种话对我来说感觉就跟没说一样。调试过程能测试出产品质量么?用调试来代替测试概念,这是缺乏对bug的认识的一个看法。
      

  10.   

    你要学习测试基础,看看怎样设置测试用例才能尽可能快地手工发现尽可能多的bug,只有发现了bug之后才调试(调试不是测试)。“调试时没有出错”,这说明不了任何问题。
      

  11.   

    另外,asp.net的异常页面只会在一场信息Message中打印最顶层的信息。你应该自己进行错误捕获程序来打印各层的错误(在aspx以及Global.asax中任何一个地方都可以),例如程序是:              Exception exp = Server.GetLastError;
                while (exp != null)
                {
                    打印exp的message和stackTrace属性(exp);
                    exp = exp.InnerException;
                }这里的关键是你起码要知道Exception是有InnerException的,是个嵌套结构!但你看到   Exception Details: System.Exception: 未指定的错误 这个提示时,你应该想到自己要看看这个Exception内部嵌套的1层或者2层,真正的异常信息往往在内部的1、2层上显示。
      

  12.   

    public static int ExecuteSql(string SQLString) 
            { 
                using (OleDbConnection connection = new OleDbConnection(connectionString)) 
                { 
                    using (OleDbCommand cmd = new OleDbCommand(SQLString, connection)) 
                    { 
                        try 
                        { 
                            connection.Open(); 
                            int rows = cmd.ExecuteNonQuery(); 
                            return rows; 
                        } 
                        catch (System.Data.OleDb.OleDbException E) 
                        { 
                            connection.Close(); 
                            throw new Exception(E.Message); 
                        } 
                    } 
                } 
            } 
    怀疑你上面这么使用连接有问题,如果同时很多人调用,打开连接会很多,可能达到数据库连接最大数目。
      

  13.   

    总结了一下:1.你可以把SQL在数据库中执行以下看看看你的SQL有问题么
    2.设置断点调试,呵呵