表单提交,在页面中点提交按钮时把数据提交到数据库的表中保存,怎么做到,求代码.......
求asp格式的数据库名:binghe表名:liuyanban表结构:liuyan_nameliuyan_qqliuyan_note...
求asp格式的
数据库名:binghe
表名:liuyanban
表结构:liuyan_name liuyan_qq liuyan_note 展开
数据库名:binghe
表名:liuyanban
表结构:liuyan_name liuyan_qq liuyan_note 展开
1个回答
2011-07-11
展开全部
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>");
}
{
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的吗?
这个不用接受页面吗?
这段代码加到哪里?谢谢了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询