1.写入
DataAccess.Da dac = new DataAccess.Da();
string strCity = this.s_city.Text;
string strb = this.TextBox1.Text;
string sql = "insert into city_info(city,sort) values ('" + strCity + "','" + strb + "')";
dac.ExecuteSql(sql);
Response.Write("<script> alert('添加成功!');window.location.href=window.location.href; </script> ");
2.修改
int id = Convert.ToInt32(Session["userid"]);
string strimg = imgUpload.ImageUrl;
string strnicheng = this.TextBox1.Text;
string strshouji = this.TextBox2.Text;
string stremail = this.TextBox3.Text;
string sql = "update tb_user set nicheng = '" + strnicheng + "',shouji = '" + strshouji + "',youxiang = ' " + stremail + "' ,touxiang = ' " + strimg + "'where ID =" + id;
BaseClass.ExecNonQuery(sql);
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language=javascript> alert('修改成功!');window.location.href=window.location.href;</script>");