update 语句 如下 update tuser set a=@a ,b = @b ,c=@c where id = @id 如何用 c# 获取 a,b,c,id@a,@b,@c,@id感谢。感谢。
 

解决方案 »

  1.   

    把update做成一个方法。比如:
    public void Update(int a,int b,string c)
    {

    StringBuilder strSql=new StringBuilder();
    strSql.Append("Update table set a=@a ,b = @b ,c=@c");
    strSql.Append(" where id=@id");
       SqlParameter[] parameters = {
                        new SqlParameter("@a", SqlDbType.Int),
                        new SqlParameter("@b", SqlDbType.Int),
                        new SqlParameter("@c", SqlDbType.NVarChar,200),
                        parameters[0].Value = model.a;
                       parameters[1].Value = model.b;
                       parameters[2].Value = model.c;
     return SqlHelper.ExecuteSql(SqlHelper.EssenceSql, strSql.ToString(), parameters) > 0;
                }; sqlhelper.ExecuteSql(strSql.ToString(),parameters);
    }
      

  2.   

    你在页面上用这方法的时候传就可以了。比如:XX.Update(textbox1.text,textbox2.text,textbox3.text,)
      

  3.   

    大家可能误解我了,我的意图是,我定义好了 update 语句,希望可以自动获取 update 的参数,也就是@aaa然后需要我做的就是给参数赋值,再然后就是 ExecuteNonQuery ,你们懂的。这样可以使系统更加灵活。请大家帮忙。