当前位置: 代码迷 >> ASP.NET >> 如何把页面上录入的信息在按了提交按钮后存入到数据库的表中
  详细解决方案

如何把页面上录入的信息在按了提交按钮后存入到数据库的表中

热度:7514   发布时间:2013-02-25 00:00:00.0
怎么把页面上录入的信息在按了提交按钮后存入到数据库的表中?
怎么把页面上录入的信息在按了提交按钮后存入到数据库的表中?比如我有三个TextBox文本输入框,ID名分别为job_name,job_address,job_telephone.我在三个文本框中输入的信息在点击了Button按钮(Button按钮名为Button)后要能存入数据库Person的表HY_GRXX中。如图

------解决方案--------------------------------------------------------
C# code
protected void Button1_Click(object sender, EventArgs e){    string name = job_name.Text;    string address = job_address.Text;    string telephone = job_telephone.Text;    SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["连接字符串"]);    conn.Open();    SqlCommand cmd = new SqlCommand("", conn);    cmd.CommandText = "insert into HY_GRXX (job_name,job_address,job_telephone) value ('" + name + "','" + address + "','" + telephone + "')";    int i = cmd.ExecuteNonQuery();    if (i > 0)    {        Response.Write("<script>alert('提示信息:操作成功!');</script>");    }    conn.Close();}
  相关解决方案