存储过程:
CREATE proc wanshang
@ws_id varchar(20),@ws_xm varchar(20),@ws_age varchar(10),@ws_sex char(10),@ws_card varchar(20),
@ws_no varchar(30),@ws_sheng varchar(20),@ws_city varchar(20),@ws_phone varchar(20),
@ws_tel varchar(20),@ws_address varchar(40),@ws_post varchar(10),@ws_xuexiao varchar(40),
@ws_work varchar(40),@ws_blood varchar(20),@ws_xingzuo varchar(20),
@ws_shengxiao char(10),@ws_country varchar(20),@ws_web varchar(30),@ws_intro varchar(100)
as
update Users set
User_card_type=@ws_card,User_No=@ws_no,User_true_name=@ws_xm,User_sex=@ws_sex,User_age=@ws_age,
User_phone=@ws_phone,User_tel=@ws_tel,User_address=@ws_address,User_post=@ws_post,User_work=@ws_work,
User_blood=@ws_blood,User_xingzuo=@ws_xingzuo,User_shengxiao=@ws_shengxiao,User_country=@ws_country,
User_province=@ws_sheng,User_city=@ws_city,User_school=@ws_xuexiao,User_web=@ws_web,User_intro=@ws_intro
where User_name=@ws_id
GO
代码:
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand com=new SqlCommand("wanshang",myConnection);
com.CommandType=CommandType.StoredProcedure;
com.Parameters.Add(new SqlParameter("@ws_card",SqlDbType.VarChar,20));
com.Parameters["@ws_card"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_no",SqlDbType.VarChar,30));
com.Parameters["@ws_no"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_xm",SqlDbType.VarChar,20));
com.Parameters["@ws_xm"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_sex",SqlDbType.Char,10));
com.Parameters["@ws_sex"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_age",SqlDbType.VarChar,10));
com.Parameters["@ws_age"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_phone",SqlDbType.VarChar,20));
com.Parameters["@ws_phone"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_tel",SqlDbType.VarChar,20));
com.Parameters["@ws_tel"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_address",SqlDbType.VarChar,40));
com.Parameters["@ws_address"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_post",SqlDbType.VarChar,10));
com.Parameters["@ws_post"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_work",SqlDbType.VarChar,40));
com.Parameters["@ws_work"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_blood",SqlDbType.VarChar,20));
com.Parameters["@ws_blood"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_xingzuo",SqlDbType.VarChar,20));
com.Parameters["@ws_xingzuo"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_shengxiao",SqlDbType.Char,10));
com.Parameters["@ws_shengxiao"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_country",SqlDbType.VarChar,20));
com.Parameters["@ws_country"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_sheng",SqlDbType.VarChar,20));
com.Parameters["@ws_sheng"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_city",SqlDbType.VarChar,20));
com.Parameters["@ws_city"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_xuexiao",SqlDbType.VarChar,40));
com.Parameters["@ws_xuexiao"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_web",SqlDbType.VarChar,30));
com.Parameters["@ws_web"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_intro",SqlDbType.VarChar,100));
com.Parameters["@ws_intro"].Direction=ParameterDirection.Input;
com.Parameters.Add(new SqlParameter("@ws_id",SqlDbType.VarChar,20));
com.Parameters["@ws_id"].Direction=ParameterDirection.Input;
com.Parameters["@ws_card"].Value=drCardtype.SelectedValue.Trim();
com.Parameters["@ws_no"].Value=txtNo.Text.Trim();
com.Parameters["@ws_xm"].Value=txtName.Text.Trim();
com.Parameters["@ws_sex"].Value=drSex.SelectedValue.Trim();
com.Parameters["@ws_age"].Value=txtAge.Text.Trim();
com.Parameters["@ws_phone"].Value=txtPhone.Text.Trim();
com.Parameters["@ws_tel"].Value=txtTel.Text.Trim();
com.Parameters["@ws_address"].Value=txtAddress.Text.Trim();
com.Parameters["@ws_post"].Value=txtPost.Text.Trim();
com.Parameters["@ws_work"].Value=drWork.SelectedValue.Trim();
com.Parameters["@ws_blood"].Value=drBlood.SelectedValue.Trim();
com.Parameters["@ws_xingzuo"].Value=drXingzuo.SelectedValue.Trim();
com.Parameters["@ws_shengxiao"].Value=drShengxiao.SelectedValue.Trim();
com.Parameters["@ws_country"].Value=drCountry.SelectedValue.Trim();
com.Parameters["@ws_sheng"].Value=drProvince.SelectedValue.Trim();
com.Parameters["@ws_city"].Value=drCity.SelectedValue.Trim();
com.Parameters["@ws_xuexiao"].Value=txtSchool.Text.Trim();
com.Parameters["@ws_web"].Value=txtWeb.Text.Trim();
com.Parameters["@ws_intro"].Value=txtIntro.Text.Trim();
com.Parameters["@ws_id"].Value=Session["name"].ToString().Trim();
try
{
com.ExecuteNonQuery();
}
catch(Exception eg)
{
Response.Write(eg.ToString());
}
com.Connection.Close();