写反了吧?应该是先加一再取值
UPDATE QUANQIU SET COUNT=COUNT+1 WHERE ID=@ID 
SELECT * FROM QUANQIU WHERE ID=@ID

解决方案 »

  1.   


    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(); //重新梆一次
      

  2.   

    你看下数据库里的数据边了没啊
    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(); 
    这样看看
      

  3.   

    你的代码写在哪儿?page_load吗?
      

  4.   

        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();
    请大家帮忙看看,是哪里错了,谢谢,我的数据库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 !!!
      

  5.   


    update完了才应读取出来。