异常详细信息: System.Data.SqlClient.SqlException: ',' 附近有语法错误。
源错误:
行 47:
行 48: DataSet ST_ds = new DataSet();
行 49: ST_myCmd.Fill(ST_ds,"新闻查看");
行 50:
行 51: DataSet ST_classds = new DataSet();
源文件: d:\TestWeb\myBLog\ST_show.aspx.cs 行: 49
堆栈跟踪:
[SqlException (0x80131904): ',' 附近有语法错误。]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2074350
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5066444
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
System.Data.SqlClient.SqlDataReader.get_MetaData() +86
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +311
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +987
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +10
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +144
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +319
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92
ST_GROUP.Blog.ST_show.Page_Load(Object sender, EventArgs e) in d:\TestWeb\myBLog\ST_show.aspx.cs:49
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
c#源代码
protected void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (IsSafe(Request.QueryString["id"],2)==false)
{
Response.Write("非法参数,<a href=BlogIndex.aspx>点此返回</a>");
Response.End();
}
string ST_dns = ConfigurationSettings.AppSettings["conStr"];
string ST_sql = "select * from ST_news where ST_n_id=" +Request.QueryString["id"] +"";
//最新推荐文章
string ST_cmd_sql = "select top 10 * from ST_news where ST_n_iscmd=1 order by ST_n_id desc";
ST_myConn = new SqlConnection(ST_dns);
SqlDataAdapter ST_myCmd = new SqlDataAdapter(ST_sql,ST_myConn);
SqlDataAdapter ST_classCmd = new SqlDataAdapter("select ST_c_id,ST_c_name from ST_class",ST_myConn);
SqlDataAdapter ST_cmdCmd = new SqlDataAdapter(ST_cmd_sql,ST_myConn);
DataSet ST_ds = new DataSet();
ST_myCmd.Fill(ST_ds,"新闻查看");
DataSet ST_classds = new DataSet();
ST_classCmd.Fill(ST_classds,"类别列表");
DataSet ST_cmdds = new DataSet();
ST_cmdCmd.Fill(ST_cmdds,"推荐文章");
NewsShow.DataSource = ST_ds.Tables[0];
NewsShow.DataBind();
ClassList.DataSource = new DataView(ST_classds.Tables[0]);
ClassList.DataBind();
CmdList.DataSource = new DataView(ST_cmdds.Tables[0]);
CmdList.DataBind();
//调用ST_UpdateHit()方法
ST_UpdateHit();
if (Request.Cookies["colors"]!=null)
{
string ST_test = Request.Cookies["colors"].Value;
String[] ST_colorList = ST_test.Split(new char[] { ',' });
ST_bgcolor = ST_colorList[0];
ST_tcolor = ST_colorList[1];
}
else
{
ST_bgcolor = "#FFDE94";
ST_tcolor = "#efe3ce";
}
Page.DataBind();
} |