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

📄 mmbh.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;

namespace ltq
{
	/// <summary>
	/// mmzh 的摘要说明。
	/// </summary>
	public class mmbh: System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Label Label7;
		protected System.Web.UI.WebControls.HyperLink HyperLink1;
		protected System.Web.UI.WebControls.TextBox xuehao;
		protected System.Web.UI.WebControls.TextBox mima;
		protected System.Web.UI.WebControls.TextBox mima1;
		protected System.Web.UI.WebControls.TextBox tishiwt;
		protected System.Web.UI.WebControls.TextBox huidawt;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
		protected System.Web.UI.WebControls.CompareValidator CompareValidator1;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
		protected System.Data.OleDb.OleDbConnection oleDbConnection1;
		protected System.Data.OleDb.OleDbCommand oleDbCommand1;
		protected System.Web.UI.WebControls.Label Label8;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
		protected System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
	    protected System.Data.OleDb.OleDbConnection oleDbConnection2;
		protected ltq.DataSet3 dataSet31;
		protected System.Web.UI.WebControls.TextBox ysmima;
		protected System.Web.UI.WebControls.Label Label9;
		protected System.Web.UI.WebControls.Label Label4;
		
		public void FillDataSet(ltq.DataSet3 dataSet) {
			// 在填充数据集前关闭约束检查。
			// 这允许适配器填充数据集而不用考虑
			// 表之间的依赖项。
			dataSet.EnforceConstraints = false;
			try {
				// 打开连接。
				this.oleDbConnection1.Open();
				// 尝试通过 OleDbDataAdapter1 填充数据集。
				this.oleDbDataAdapter1.Fill(dataSet);
			}
			catch (System.Exception fillException) {
				// 在此处添加错误处理代码。
				throw fillException;
			}
			finally {
				// 重新打开约束检查。
				dataSet.EnforceConstraints = true;
				// 无论是否引发了异常都关闭连接。
				this.oleDbConnection1.Close();
			}

		}
		public void LoadDataSet() {
			// 创建一个新数据集以保存从 FillDataSet 调用返回的记录。
			// 使用了一个临时数据集,这是因为填充现有的数据集
			// 需要重新绑定数据绑定。
			ltq.DataSet3 objDataSetTemp;
			objDataSetTemp = new ltq.DataSet3();
			try {
				// 尝试填充临时数据集。
				this.FillDataSet(objDataSetTemp);
			}
			catch (System.Exception eFillDataSet) {
				// 在此处添加错误处理代码。
				throw eFillDataSet;
			}
			try {
				// 清空数据集中的旧记录。
				dataSet31.Clear();
				// 将记录合并到主数据集中。
				dataSet31.Merge(objDataSetTemp);
			}
			catch (System.Exception eLoadMerge) {
				// 在此处添加错误处理代码。
				throw eLoadMerge;
			}

		}
		private void Page_Load(object sender, System.EventArgs e)
		{
  // 在此处放置用户代码以初始化页面
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent() 
		{
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e) 
		{
		 this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
			this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
			this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
				
			// 
			// oleDbDataAdapter1
			// 
			
			this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
			this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									new System.Data.Common.DataTableMapping("Table", "mima", new System.Data.Common.DataColumnMapping[] {
																																																			new System.Data.Common.DataColumnMapping("学号", "学号"),
																																																			new System.Data.Common.DataColumnMapping("姓名", "姓名"),    
																																																			new System.Data.Common.DataColumnMapping("密码", "密码")})});
			// 
			// oleDbSelectCommand1
			// 
			this.oleDbSelectCommand1.CommandText = "SELECT * FROM mima where 学号='"+xuehao.Text+"'";
			this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
			// 
			
			// oleDbConnection1
			// 
			this.oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Documents and Settings\Administrator\My Documents\xscjcx.mdb;Mode=ReadWrite;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
			this.dataSet31 = new ltq.DataSet3();
			((System.ComponentModel.ISupportInitialize)(this.dataSet31)).BeginInit();
				
			// 
			// dataSet11
			// 
			
			this.dataSet31.DataSetName = "DataSet3";
			this.dataSet31.Locale = new System.Globalization.CultureInfo("en-US");
			this.dataSet31.Namespace = "http://tempuri.org/DataSet1.xsd";
			((System.ComponentModel.ISupportInitialize)(this.dataSet31)).EndInit();
			
	
			try {
				this.LoadDataSet();
					
			}
			catch (System.Exception eLoad) {
				this.Response.Write(eLoad.Message);
			}
			if (0==dataSet31.Tables["mima"].Rows.Count||ysmima.Text!=dataSet31.Tables["mima"].Rows[0]["密码"].ToString())
			{
			Response.Redirect ("error.htm");
				 
			}

			else{
				this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
				this.oleDbCommand1 = new System.Data.OleDb.OleDbCommand();
			
			 
				//oleDbConnection1
				// 
				this.oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Documents and Settings\Administrator\My Documents\xscjcx.mdb;Mode=ReadWrite;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
				// 
				// oleDbCommand1
				// 
				this.oleDbCommand1.CommandText =@"UPDATE mima set 密码='"+mima.Text+"',学号='"+xuehao.Text+"',提示问题='"+tishiwt.Text+"',回答问题='"+huidawt.Text+"' where 学号='"+xuehao.Text+"'";
				this.oleDbCommand1.Connection = this.oleDbConnection1;
			
				try {
					this.oleDbCommand1.Connection.Open();
					this.oleDbCommand1.ExecuteNonQuery();
				}
				catch {
					Response.Write("数据库读写错误");
				}
				finally {
					this.oleDbCommand1.Dispose();
					this.oleDbConnection1.Close();
				}
				Response.Redirect ("cgdl.aspx?xuehao="+xuehao.Text+"");
			}
		}

		
	}
}

⌨️ 快捷键说明

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