reg.aspx.cs
上传用户:vtryaojia
上传日期:2020-04-18
资源大小:1214k
文件大小:2k
源码类别:

SCSI/ASPI

开发平台:

Others

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.OleDb;
  12. public partial class reg : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.     }
  17.     protected void regButton_Click(object sender, EventArgs e)
  18.     {
  19.         string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/App_Data/zzu.mdb") + ";";
  20.         OleDbConnection conn = new OleDbConnection(strConnection);
  21.         conn.Open();
  22.         string sqlstr = "select * from Member where Name='" + UserName.Text + "'";
  23.         OleDbCommand cmd = new OleDbCommand(sqlstr, conn);
  24.         OleDbDataReader dr;
  25.         dr = cmd.ExecuteReader();
  26.         if (dr.Read())
  27.         {
  28.             Response.Write("<script language=javascript>alert('用户名已经存在');</script>");
  29.             dr.Close();
  30.         }
  31.         else
  32.         {
  33.             dr.Close();
  34.             string SqlString = "INSERT INTO Member([Name],[Password],[PhoneCode],[Address],[Email]) VALUES ('" + UserName.Text + "','" + Password1.Text + "', '" + Telephone.Text + "','" + Address.Text + "','" + this.Email.Text.ToString() + "')";
  35.             OleDbCommand cmd2 = new OleDbCommand(SqlString, conn);
  36.             cmd2.ExecuteNonQuery();
  37.             //string Email = string.Empty;
  38.             //Email = Email.Trim();
  39.             //string SqlString = "INSERT INTO Member([Name],[Password],[PhoneCode],[Address],[Email]) VALUES ('" + UserName.Text + "','" + Password1.Text + "', '" + Telephone.Text + "','" + Address.Text + "','" + this.Email.Text.ToString() + "')";
  40.             //OleDbCommand cmd2 = new OleDbCommand(SqlString, conn);
  41.             //cmd2.ExecuteNonQuery();
  42.             Response.Redirect("regsuccess.aspx");
  43.         }
  44.     }
  45. }
  46.    
  47.       
  48.         
  49.