表time 
id  name     url   t_bname    title 1    xiao   c.cn   zhang      null 
2    mali   g.cn   zhang      null 
3    juer   b.cn   zhang      null 
4    juer   t.cn   wang       null 
string but= Request["id"].ToString(); 
but的值为adminxia 我有一个button 当点击button 时候得到的结果是 
表time 
id  name     url   t_bname    title 
1    xiao   c.cn   zhang      adminxia
2    mali   g.cn   zhang      adminxia 
3    juer   b.cn   zhang      adminxia 
4    juer   t.cn   wang       null 

解决方案 »

  1.   


    string str_sql="select [id],[name],url,t_bname,title=case when t_bname='wang' then '"+but+"'  else null end from time"
      

  2.   

    SqlConnection myConnection = new SqlConnection("server=.;uid=sa;pwd=123456;database=master");
    string str="update time set title='"+but+"' where t_bname='zhang'";
    SqlCommand myCommand = new SqlCommand(str, myConnection);
    myCommand.EndExecuteNonQuery();
      

  3.   

    在数据库里你可以写个存储过程create procedure update_time_title
    @title varchar(30),
    as
    update time
    set title=@title
    where t_bname='zhang'
    go
    在页面后台的代码如下:SqlConnection con= new SqlConnection("server=.;uid=sa;pwd=;database=your_tablename");  
    SqlCommand cmd= new SqlCommand(); 
    cmd.Connection=con;
    cmd.CommandText ="update_time_title";//存储过程名
    cmd.CommandType=CommandType.StoredProcedure;
    cmd.Parameters.Add("@title",SqlDbType.Varchar)=but;
    con.open();
    myCommand.ExecuteNonQuery();
    con.Close();
      

  4.   

    update time set title=xxxxx where .......
      

  5.   

    Update语句:
    Update 表名 set 列名1=值1,列名2=值1,... where 条件