在本地可以完全运行,但传到服务器上后,到后台操作一段时间就会报错,有时好有时坏,
已下错误信息:: 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);
}
}
}
}
//等...其它通用的一些方法,全是静态的
}
已下错误信息:: 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);
}
}
}
}
//等...其它通用的一些方法,全是静态的
}
解决方案 »
- 截取字符问题!
- 关于viewstate我又迷糊了.期待绝顶高手出现
- 有关gridview这样地格式显示问题,很难的,请高手指点
- 求助关于Cache的一个问题
- 那位高手能给个好一点的答复?小第不胜感激!顶者有分!
- 如何把已经存在的静态页转化成ASP.NET页?
- 用showModalDialog打开的模式窗口中的标题栏能去掉吗?怎么去?如果不能去,怎么改标题?
- 谁能给我个datalist分页的简单例子
- 关于进度条的问题
- Entity Formwork中这种数据关系,怎么创建MAP映射
- 急急。。URL重写。。在ISS里执行出错。。在Visual Studio里就没错
- 求救关于Session的监听器功能!!!!!
你先看看你的系统日志,有没有什么错误,类似于:
系统日志具体描述如下: 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
建议使用try_catch获取具体的出错位置与信息。
要根据异常的堆栈信息来找问题,就好像你给出public static int ExecuteSql(string SQLString) 方法,你想说明跟堆栈信息又有什么关系呢?通常你可以在login.ImgButLogin_Click(Object sender, ImageClickEventArgs e) +269 这里设置一个日志(比如只是一个简单的文本文件),将调用 DbHelperSQL.Exists(String strSql) 时使用的strSql记录下来,这样你就可以在发现bug时看出最后的sql语句是什么。然后贴出这个sql来。
质量好的系统,应该经过自动化测试,而不是手工测试。如果程序上线前一有空闲时间就使用自动化测试,那么上线时已经曾经从数据库中随机生成100万次测试数据,这类bug很可能早已经不经意间早已经解决了(甚至不觉得花了什么时间)。手工测试只能发现少量问题,而大量使用了一段时间才偶尔发生的问题则仍然会浪费你大量时间,而且这些问题都是发生在上线之后造成的损失其实是很大的。
while (exp != null)
{
打印exp的message和stackTrace属性(exp);
exp = exp.InnerException;
}这里的关键是你起码要知道Exception是有InnerException的,是个嵌套结构!但你看到 Exception Details: System.Exception: 未指定的错误 这个提示时,你应该想到自己要看看这个Exception内部嵌套的1层或者2层,真正的异常信息往往在内部的1、2层上显示。
{
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);
}
}
}
}
怀疑你上面这么使用连接有问题,如果同时很多人调用,打开连接会很多,可能达到数据库连接最大数目。
2.设置断点调试,呵呵