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

2024-11-24 03:18:25
推荐回答(1个)
回答1:

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("");
}