⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zhuce2.aspx.cs

📁 搜索图书
💻 CS
字号:
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.Odbc;

using System.Data.OleDb;

namespace BBK
{
	/// <summary>
	/// zhuce2 的摘要说明。
	/// </summary>
	public partial class zhuce2 : System.Web.UI.Page
	{
		protected System.Data.Odbc.OdbcConnection odbcConnection1;
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.odbcConnection1 = new System.Data.Odbc.OdbcConnection();
			// 
			// odbcConnection1
			// 
			this.odbcConnection1.ConnectionString = "DSN=mybbk;DefaultDir=F:\\好轻松网站\\BBK\\DATABASE;DriverId=25;DBQ=F:\\好轻松网站\\BBK\\DATABASE\\" +
				"bbk.mdb;MaxBufferSize=2048;FIL=MS Access;PageTimeout=5;UID=admin";

		}
		#endregion

		private void Submit1_ServerClick(object sender, System.EventArgs e)
		{
			//注册

		}
		private bool IsOne()
		{
			int n =0;
			string dbname=Server.MapPath("database/bbk.mdb");
			string 	strcon= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+dbname;
			OleDbConnection olecon=new OleDbConnection(strcon);		
			string sql="select * from U where userid='"+ TextBox1.Text +"'";
			OleDbCommand olecom=new OleDbCommand(sql,olecon);
			olecon.Open();
			OleDbDataReader reader=olecom.ExecuteReader ();      
			reader.Read ();
			if (reader.HasRows ==false)
			{
				return true;
			}
			else
			{
				return false;
			}			
			olecon.Close();

		}

		protected void Button1_Click(object sender, System.EventArgs e)
		{
			if(Page.IsValid)
			{
				if (IsOne()==false)
				{
					Response.Write("<script language=javascript>alert(' 此用户名已经存在,请输入其他的用户名!!')</script>");
					TextBox1.Text ="";
					return;
				}
				if (TextBox3.Text !=TextBox4.Text )
				{
					Response.Write("<script language=javascript>alert('您两次输入的密码不一致!!')</script>");
					return;
				}
   			string dbname=Server.MapPath("database/bbk.mdb");
//				string 	strcon= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+dbname;
				string 	strcon= @"Driver={Microsoft Access Driver (*.mdb)};Dbq="+ dbname +";Uid=Admin;Pwd=";

				OdbcConnection olecon=new OdbcConnection(strcon);		
				
//				OleDbConnection olecon=new OleDbConnection(strcon);		
//				//string sql="insert into  u (UserId,UserName,Password,sex,phone,mobile,email,address ) values ( '"+TextBox1.Text+"','"+TextBox2.Text+"','"+TextBox4.Text+"','"+sex.Value +"','"+TextBox5.Text+"','"+TextBox6.Text+"','"+TextBox7.Text+"') ";
				string sql="insert into U  (userid,Pass ) values( '"+TextBox1.Text+"','"+TextBox4.Text+"') ";
				OdbcCommand olecom=new OdbcCommand(sql,olecon);
//				OleDbCommand olecom=new OleDbCommand(sql,olecon);
				olecon.Open();
				olecom.ExecuteNonQuery();
				olecon.Close();
				Response.Redirect ("Success.aspx");


			}		
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -