日期:2014-05-18 浏览次数:20459 次
protected void Button1_Click(object sender, EventArgs e) { //access链接字符串 string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=" + Server.MapPath("~\\DataBase\\#wulong.mdb"); //生成一个新的连接 string sql = "Insert Into users (UserName,Password,Lm)values('" + UserName.Text.ToString() + "','" + Password.Text.ToString() + "','" + Lm.SelectedValue.ToString() + "')"; //Response.Write(sql); //Response.End(); OleDbConnection myConn = new OleDbConnection(strConn); OleDbCommand InsCommand = new OleDbCommand(sql, myConn); myConn.Open(); InsCommand.ExecuteNonQuery(); myConn.Close(); Response.Write("<script> alert('用户资料添加成功!');window.location.href='UserEdit.aspx';</script>"); }