public partial class reg : System.Web.UI.Page
{
private static OleDbConnection conn;
private static OleDbCommand comm;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string connstr = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath(ConfigurationSettings.AppSettings["server"]);
conn = new OleDbConnection(connstr);
conn.Open();
string id = this.id.Text;
string pwd = this.pwd.Text;
string mail = this.mail.Text;
string tel = this.tel.Text;
string dz = this.dz.Text;
string date = System.DateTime.Now.ToString();
string lab=this.Label1.Text;
rrd = new OleDbCommand("select * from userxxx where username='" + id + "'");
if (rrd.Read())
{
lab="用户名被注册";
}
else
{
string tj = ("Insert into [userxxx] ([username],[password],mail,tel,dz,[date]) values ('" + id + "','" + pwd + "','" + mail + "','" + tel + "','" + dz + "','" + date + "')");
comm = new OleDbCommand(tj, conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Write("<script language=javascript> alert('数据提交成功');</script>");
}
}
}