首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

网站的log.txt,爆这样的异常,要如何维护啊

2012-10-19 
网站的log.txt,爆这样的错误,要怎么维护啊。System.Data.SqlClient.SqlException: , 附近有语法错误。关键

网站的log.txt,爆这样的错误,要怎么维护啊。
System.Data.SqlClient.SqlException: ',' 附近有语法错误。
关键字 'as' 附近有语法错误。
关键字 'as' 附近有语法错误。
关键字 'as' 附近有语法错误。
关键字 'as' 附近有语法错误。
关键字 'as' 附近有语法错误。
')' 附近有语法错误。
  在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
  在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
  在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
  在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
  在 System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
  在 System.Data.SqlClient.SqlDataReader.get_MetaData()
  在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
  在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
  在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
  在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
  在 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
  在 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
  在 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
  在 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
  在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
  在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
  在 LHZ.Website.Common.Utility.SqlHelper.FillDataset(SqlConnection connection, SqlTransaction transaction, CommandType commandType, String commandText, DataSet dataSet, String[] tableNames, SqlParameter[] commandParameters)
  在 LHZ.Website.Common.Utility.SqlHelper.FillDataset(SqlConnection connection, CommandType commandType, String commandText, DataSet dataSet, String[] tableNames, SqlParameter[] commandParameters)
  在 LHZ.Website.Common.Utility.SqlHelper.FillDataset(String connectionString, CommandType commandType, String commandText, DataSet dataSet, String[] tableNames, SqlParameter[] commandParameters)
  在 LHZ.Website.ProductList.DAL.ProductDAL.GetProductListByCondition(Int32 CategoryID, Int32 BrandID, Int32 Page, Int32 PageSize, String SortCol, Int32 ProductGroupID, Int32 ProductTypeID, String keywords, Int32 sex, Int32 style, String colorname, Decimal pricefrom, Decimal priceto, Int32 tagID, Int32& TotalNum)
  在 LHZ.Website.ProductList.BLL.ProductBLL.GetProductListByCondition(Int32 CategoryID, Int32 BrandID, Int32 Page, Int32 PageSize, String SortCol, Int32 ProductGroupID, Int32 ProductTypeID, String keywords, Int32 sex, Int32 style, String colorname, Decimal pricefrom, Decimal priceto, Int32 tagID, Int32& TotalNum) 2012-3-31 11:13:01


通过log.txt 我知道 是GetProductListByCondition这个方法下调用的FillDataset方法调用的...(省略N个方法)最终导致了System.Data.SqlClient.SqlConnection.OnError的异常。
可能是输入参数,或者查询条件有问题,但是问题来了,我不知道哪里有错误,哪个参数 没有检查,不能定位错误的地方,无法模拟再现错误的情况。求帮助啊。之前试过 “穿山甲”SQL注入测试工具,但是不是很会用。

[解决办法]
sql语句有语法错误,自己查吧,特别对于用变量拼接的,如果变量值为 "" 空字符串,就很容易产生这错误
------解决方案--------------------


System.Data.SqlClient.SqlException: ',' 附近有语法错误。
关键字 'as' 附近有语法错误。
关键字 'as' 附近有语法错误。
关键字 'as' 附近有语法错误。
关键字 'as' 附近有语法错误。
关键字 'as' 附近有语法错误。
')' 附近有语法错误。
=====================================
系统已经给出了出现错误的提示,sql语句有错误,把具体的sql语句写入log中,查看sql,查找具体错误。
[解决办法]

探讨
sql语句有语法错误,自己查吧,特别对于用变量拼接的,如果变量值为 "" 空字符串,就很容易产生这错误

[解决办法]
探讨

引用:
sql语句有语法错误,自己查吧,特别对于用变量拼接的,如果变量值为 "" 空字符串,就很容易产生这错误

正解

[解决办法]
其实应该很简单的吧,你把你用双引号连接的sql前后添加一个空格就好了比如 "select * from t_table where id= "+txtID.Text+" and name= "+txtName.Text;
[解决办法]
调试看看你SQL语句成什么了

热点排行
Bad Request.