求救,错误详细信息: System.Data.SqlClient.SqlException: 第 1 行: '=' 附近有语法异常
求救,异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '=' 附近有语法错误。
这是我的代码:
求救,第1行有错误!!!
这是我的代码
protected void Page_Load(object sender, System.EventArgs e)
{
SqlConnection ST_myConn = new SqlConnection();
string ST_dns = ConfigurationSettings.AppSettings[ "strConn "];
ST_myConn.ConnectionString = ST_dns;
string ST_sql = "select * from B_news where B_id= " + Request.QueryString[ "id "] + " ";
SqlDataAdapter ST_myCmd = new SqlDataAdapter(ST_sql, ST_myConn);
DataSet ST_ds = new DataSet();
ST_myCmd.Fill(ST_ds, "NewsCheck ");
NewsShow.DataSource = ST_ds.Tables[0].DefaultView;
NewsShow.DataBind();
}
执行的时候提示异常详细信息: 异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '= ' 附近有语法错误。
源错误:
行 38:
行 39: DataSet ST_ds = new DataSet();
行 40: ST_myCmd.Fill(ST_ds, "NewsCheck ");
行 41: NewsShow.DataSource = ST_ds.Tables[0].DefaultView;
行 42: NewsShow.DataBind();
请问这是怎么回事啊?????
------解决方案--------------------
"select * from B_news where B_id= " + Request.QueryString[ "id "] + " ";
改成
"select * from B_news where B_id= ' " + Request.QueryString[ "id "] + " ' ";
这是我的代码:
求救,第1行有错误!!!
这是我的代码
protected void Page_Load(object sender, System.EventArgs e)
{
SqlConnection ST_myConn = new SqlConnection();
string ST_dns = ConfigurationSettings.AppSettings[ "strConn "];
ST_myConn.ConnectionString = ST_dns;
string ST_sql = "select * from B_news where B_id= " + Request.QueryString[ "id "] + " ";
SqlDataAdapter ST_myCmd = new SqlDataAdapter(ST_sql, ST_myConn);
DataSet ST_ds = new DataSet();
ST_myCmd.Fill(ST_ds, "NewsCheck ");
NewsShow.DataSource = ST_ds.Tables[0].DefaultView;
NewsShow.DataBind();
}
执行的时候提示异常详细信息: 异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '= ' 附近有语法错误。
源错误:
行 38:
行 39: DataSet ST_ds = new DataSet();
行 40: ST_myCmd.Fill(ST_ds, "NewsCheck ");
行 41: NewsShow.DataSource = ST_ds.Tables[0].DefaultView;
行 42: NewsShow.DataBind();
请问这是怎么回事啊?????
------解决方案--------------------
"select * from B_news where B_id= " + Request.QueryString[ "id "] + " ";
改成
"select * from B_news where B_id= ' " + Request.QueryString[ "id "] + " ' ";