首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-03-22 
怎么把页面上录入的信息在按了提交按钮后存入到数据库的表中?怎么把页面上录入的信息在按了提交按钮后存入

怎么把页面上录入的信息在按了提交按钮后存入到数据库的表中?
怎么把页面上录入的信息在按了提交按钮后存入到数据库的表中?比如我有三个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();} 

热点排行