reg.aspx.cs
资源名称:WebSite1.rar [点击查看]
上传用户:vtryaojia
上传日期:2020-04-18
资源大小:1214k
文件大小:2k
源码类别:
SCSI/ASPI
开发平台:
Others
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.OleDb;
- public partial class reg : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void regButton_Click(object sender, EventArgs e)
- {
- string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/App_Data/zzu.mdb") + ";";
- OleDbConnection conn = new OleDbConnection(strConnection);
- conn.Open();
- string sqlstr = "select * from Member where Name='" + UserName.Text + "'";
- OleDbCommand cmd = new OleDbCommand(sqlstr, conn);
- OleDbDataReader dr;
- dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- Response.Write("<script language=javascript>alert('用户名已经存在');</script>");
- dr.Close();
- }
- else
- {
- dr.Close();
- string SqlString = "INSERT INTO Member([Name],[Password],[PhoneCode],[Address],[Email]) VALUES ('" + UserName.Text + "','" + Password1.Text + "', '" + Telephone.Text + "','" + Address.Text + "','" + this.Email.Text.ToString() + "')";
- OleDbCommand cmd2 = new OleDbCommand(SqlString, conn);
- cmd2.ExecuteNonQuery();
- //string Email = string.Empty;
- //Email = Email.Trim();
- //string SqlString = "INSERT INTO Member([Name],[Password],[PhoneCode],[Address],[Email]) VALUES ('" + UserName.Text + "','" + Password1.Text + "', '" + Telephone.Text + "','" + Address.Text + "','" + this.Email.Text.ToString() + "')";
- //OleDbCommand cmd2 = new OleDbCommand(SqlString, conn);
- //cmd2.ExecuteNonQuery();
- Response.Redirect("regsuccess.aspx");
- }
- }
- }