上一个文件接口在 DataNavigateUrlFormatString="detail.aspx? id = {0}" detail.aspx:<script language="c#" runat="server">
DataRow dr;
DataSet ds;
string newsid;
void Page_Load(object sender,EventArgs e)
{ SqlConnection MyConnection;
string strCon;
newsid = Request.QueryString["id"]; MyConnection = new SqlConnection("server = LST-PC;database = data;uid = sa;pwd = ''");
MyConnection.Open();
string strCom = "select biaoti,zhaizi,neirong,img,counter,shijian from news where id = "+ newsid;
ds = new DataSet();
SqlDataAdapter myCommand = new SqlDataAdapter(strCom,MyConnection);
myCommand.Fill(ds,"news");
dr = ds.Tables["news"].Rows[0];
strCon = "select counter from news where id = " + newsid;
SqlCommand myCommand2 = new SqlCommand(strCon,MyConnection);
SqlDataReader reader = myCommand2.ExecuteReader();
reader.Read();
int i = reader.GetInt32(0);
i++;
reader.Close();
strCon = "update news set counter = " + i.ToString() + " where id = " + newsid;
myCommand2.CommandText = strCon;
myCommand2.ExecuteNonQuery();
MyConnection.Close();
}
</script>
..............报错是 '=' 附近有语法错误。 我觉得应该是 newsid = Request.QueryString["id"];
接收的数据有问题 把 newsid 换成"1"就能跑了 不知道该怎么改 请高手指点
DataRow dr;
DataSet ds;
string newsid;
void Page_Load(object sender,EventArgs e)
{ SqlConnection MyConnection;
string strCon;
newsid = Request.QueryString["id"]; MyConnection = new SqlConnection("server = LST-PC;database = data;uid = sa;pwd = ''");
MyConnection.Open();
string strCom = "select biaoti,zhaizi,neirong,img,counter,shijian from news where id = "+ newsid;
ds = new DataSet();
SqlDataAdapter myCommand = new SqlDataAdapter(strCom,MyConnection);
myCommand.Fill(ds,"news");
dr = ds.Tables["news"].Rows[0];
strCon = "select counter from news where id = " + newsid;
SqlCommand myCommand2 = new SqlCommand(strCon,MyConnection);
SqlDataReader reader = myCommand2.ExecuteReader();
reader.Read();
int i = reader.GetInt32(0);
i++;
reader.Close();
strCon = "update news set counter = " + i.ToString() + " where id = " + newsid;
myCommand2.CommandText = strCon;
myCommand2.ExecuteNonQuery();
MyConnection.Close();
}
</script>
..............报错是 '=' 附近有语法错误。 我觉得应该是 newsid = Request.QueryString["id"];
接收的数据有问题 把 newsid 换成"1"就能跑了 不知道该怎么改 请高手指点
解决方案 »
- .net 中 session如何跨域保存和防止用户重复登录
- out look 有没有可以让html调用的activex
- 菜鸟求助~为什么使用在scrip中写代码会找不到页面上的控件?
- 新手请教:为用户设定权限的问题
- FreeTextBox清除Word格式的按钮在工具条定制不会显示出这个按钮
- 请问各位高手们,如何把网页里的数据导出到客户端的WORD并打开
- 怎条解决高速缓存的 SSL 页面
- 如何用Button??
- asp/js问题
- 将数据集的表存入Senssion后如何去出来???急急急!
- 请高手指教:在.NET 中如何使用dwz中的分页?
- DataSet生成XML没有生成encoding="utf-8"的问题
Substring(6) 截取id数字 。 为什么会得到+id+=+1 有人知道么? 可加QQ315032109 谢谢。。