Server Error in '/' Application.
--------------------------------------------------------------------------------第 1 行: 'System' 附近有语法错误。 
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.Data.SqlClient.SqlException: 第 1 行: 'System' 附近有语法错误。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: 
[SqlException (0x80131904): 第 1 行: 'System' 附近有语法错误。]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857466
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735078
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
   System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +192
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +380
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
   clsPublic.AddErrorMessage(String strMessage, String strSource, String strTargetSiteName) +374
   Info.Page_Load(Object sender, EventArgs e) +4771
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061 
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

解决方案 »

  1.   

    我也不知道是哪个sql语句出错啊...
      

  2.   

    string strSQL = "Insert into tb_Error(fdErrTime,fdErrPage,fdErrMessage,fdErrSource,fdErrTagName) values ('" + System.DateTime.Now.ToString() + "','" + strErrPage + "','" + strMessage + "','" + strSource + "','" + strTargetSiteName + "')";
      

  3.   

    fdErrTime在你数据库是字符型的吗?
    如果不是请去掉'" + System.DateTime.Now.ToString() + "'中的''
    string strSQL = "Insert into tb_Error(fdErrTime,fdErrPage,fdErrMessage,fdErrSource,fdErrTagName) values (" + System.DateTime.Now.ToString() + ",'" + strErrPage + "','" + strMessage + "','" + strSource + "','" + strTargetSiteName + "')";
      

  4.   

    检查一下是否插入语句的类型是否与数据库中数据类型一直;要么就把SQL语句打印出来到数据库中运行一下,仔细对照一下就知道哪里出错了啊!
      

  5.   

    sql语句改为:
    string strSQL = "Insert into tb_Error(fdErrTime,fdErrPage,fdErrMessage,fdErrSource,fdErrTagName) values (getdate(),'" + strErrPage + "','" + strMessage + "','" + strSource + "','" + strTargetSiteName + "')";