using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.OleDb; using System.Text; using System.Web.Security;
namespace log { /// <summary> /// add 的摘要说明。 /// </summary> public class add : System.Web.UI.Page { protected System.Web.UI.WebControls.TextBox users; protected System.Web.UI.WebControls.TextBox mima; protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.TextBox rights; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 } public string Encrypt(string password,int format) { string str=""; switch(format) { case 0: str=FormsAuthentication.HashPasswordForStoringInConfigFile(password,"SHA1"); break; case 1: str=FormsAuthentication.HashPasswordForStoringInConfigFile(password,"MD5"); break; } return str; }
private void Button1_Click(object sender, System.EventArgs e) { string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(".") + "..\\person.mdb"; OleDbConnection con=new OleDbConnection(constr); string passwords=mima.Text; string p=Encrypt(passwords,1); string sql="insert into users (names,levels,password) values ('" + users.Text + "','" + rights.Text +"','" + p +"')"; con.Open(); OleDbCommand com=new OleDbCommand(sql,con); com.ExecuteNonQuery();
}
} } 这个页面的作用是添加新用户,密码,和权限,编译时没有错误,但当我在textbox中填好内容后,点击添加按钮后,无法将数据插入access数据库,页面上提示的错误是insert into 语句的语法错误 可我看不出是什么错误呀``````不知道怎么改,帮我看看是哪错了,谢谢了!!!!