表单提交,在页面中点提交按钮时把数据提交到数据库的表中保存,怎么做到,求代码.......

求asp格式的
数据库名:binghe
表名:liuyanban
表结构:liuyan_name liuyan_qq liuyan_note

protected void Button1_Click(object sender, EventArgs e)
{
string s;
s = (String)Session["Pass"];
string time;
time = System.DateTime.Now.ToString();
string strconn = "Server=PC-201106261541;DataBase=binghe
;Integrated Security=true";
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
string inStr = "insert into liuyanban
(liuyan_name, liuyan_qq , liuyan_note) values('" + s + "','" + TextBox1.Text + "','" + System.DateTime.Now.ToString() + "')";
SqlCommand cmd = new SqlCommand(inStr, conn);
cmd.ExecuteNonQuery();

Response.Write("<script language=javascript>alert(提交成功!!')</script>");
}追问

是asp的吗?
这个不用接受页面吗?
这段代码加到哪里?谢谢了

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答
大家正在搜