我的代码如下
SqlConnection MyConnectionedit = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
string sqlstringedit = "UPDATE jq_num SET num=num+1 where id=1";
SqlCommand MyCommandedit=new SqlCommand(sqlstringedit, MyConnectionedit);
MyConnectionedit.Open();
MyConnectionedit.Close();SqlConnection MyConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
string sqlstring = "SELECT * FROM jq_num where id=1";
SqlDataAdapter MyCommand = new SqlDataAdapter(sqlstring, MyConnection);
DataSet ds = new DataSet();
MyCommand.Fill(ds, "jq_news");
dv = ds.Tables["jq_news"].DefaultView;
this.num.Text=ds.Tables["jq_news"].Rows[0]["num"].ToString();
MyConnection.Close();其中this.num.Text=ds.Tables["jq_news"].Rows[0]["num"].ToString();是要显示数字,可是不起作用,每次数字不加一,不知道什么原因,能帮我看看吗?谢谢啦!再线等!

解决方案 »

  1.   

    SqlConnection MyConnectionedit = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
            string sqlstringedit = "UPDATE jq_num SET num=num+1 where id=1";
            SqlCommand MyCommandedit = new SqlCommand(sqlstringedit, MyConnectionedit);
    MyCommandedit.ExecuteNonQuery();//加这句
            MyConnectionedit.Open();
            MyConnectionedit.Close();
      

  2.   

    同意楼上
    用Command 对象提供了 ExecuteNonQuery 方法来执行sql命令
      

  3.   

    报错:
    D:\JinQiao\index.aspx.cs(57): “System.Data.SqlClient.SqlConnection”并不包含对“ExecuteNonQuery”的定义