写反了吧?应该是先加一再取值
UPDATE QUANQIU SET COUNT=COUNT+1 WHERE ID=@ID
SELECT * FROM QUANQIU WHERE ID=@ID
UPDATE QUANQIU SET COUNT=COUNT+1 WHERE ID=@ID
SELECT * FROM QUANQIU WHERE ID=@ID
解决方案 »
- 哪位大哥能帮我解决一下ado.net中的事务的问题.谢谢!
- asp.net2.0中的WEBPART救急。。。。。
- ASP.NET:SQL SERVER 2008复制实现数据库同步备份
- SOS,我遇到一个最简单插入数据的错误
- 怎么同时得到存储过程的输出参数值和返回值?
- 急,急,急 如何实现点击Button按钮先执行服务器端的事件,再执行客户端的事件.
- javascript调用服务器控件的函数和事件。
- asp.net消息即时提醒
- 关于DATAGRID中的按扭问题
- :( 连接数据库的问题-我把主机拖的象蜗牛一样
- gridview分页后的总行数?
- 关于多个用户访问同一个ASPX页面上的某一个对象或变量时的问题
string txt = "select * from quanqiu where id="+_id;
SqlCommand cmd1 = new SqlCommand();
SqlDataAdapter sda = new SqlDataAdapter(txt, conn);
DataSet ds = new DataSet();
sda.Fill(ds,"biao");
Label1.Text = ds.Tables[0].Rows[0]["count"].ToString(); string sql = "update quanqiu set count=count+1 where id="+_id;
SqlCommand cmd = new SqlCommand(sql,conn);
cmd.ExecuteNonQuery(); Label1.Text = ds.Tables[0].Rows[0]["count"].ToString(); //重新梆一次
string sql = "update quanqiu set count=count+1 where id="+_id;
SqlCommand cmd = new SqlCommand(sql,conn);
cmd.ExecuteNonQuery(); string txt = "select * from quanqiu where id="+_id;
SqlCommand cmd1 = new SqlCommand();
SqlDataAdapter sda = new SqlDataAdapter(txt, conn);
DataSet ds = new DataSet();
sda.Fill(ds,"biao");
Label1.Text = ds.Tables[0].Rows[0]["count"].ToString();
这样看看
SqlCommand cmd1 = new SqlCommand();
SqlDataAdapter sda = new SqlDataAdapter(txt, conn);
DataSet ds = new DataSet();
sda.Fill(ds,"biao");
Label1.Text = ds.Tables[0].Rows[0]["count"].ToString(); string sql = "update quanqiu set count=count+1 where id="+_id;
SqlCommand cmd = new SqlCommand(sql,conn);
cmd.ExecuteNonQuery();
请大家帮忙看看,是哪里错了,谢谢,我的数据库count字段初始是0,但页面执行后,还是0,并没有加1,在线等,急!
--------------------------
有个简单一点的
Label1.Text = ds.Tables[0].Rows[0]["count"].ToString();
int tempCount = int.pease(ds.Tables[0].Rows[0]["count"].ToString()) + 1; string sql = "update quanqiu set count="+tempCount +" where id="+_id;
SqlCommand cmd = new SqlCommand(sql,conn);
---------
问题分析:
1, Label1.Text = ds.Tables[0].Rows[0]["count"].ToString();
这里是不是每次都变化了 有调试看看
2, string sql = "update quanqiu set count=count+1 where id="+_id;
这里看看语句有错误了没 或者调试看看count !!!
update完了才应读取出来。