📄 sjxs.aspx.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>
/// sjxs 的摘要说明。
/// </summary>
public class sjxs : 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 xuehao;
protected System.Web.UI.WebControls.Label xingming;
protected System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
protected System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
protected System.Data.OleDb.OleDbConnection oleDbConnection1;
protected ltq.DataSet2 dataSet21;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
this.xuehao.Text=Request.QueryString["xuehao"].ToString();
this.xingming.Text=Request.QueryString["xingming"].ToString();
// 在此处放置用户代码以初始化页面
}
public void FillDataSet(ltq.DataSet2 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.DataSet2 objDataSetTemp;
objDataSetTemp = new ltq.DataSet2();
try {
// 尝试填充临时数据集。
this.FillDataSet(objDataSetTemp);
}
catch (System.Exception eFillDataSet) {
// 在此处添加错误处理代码。
throw eFillDataSet;
}
try {
// 清空数据集中的旧记录。
dataSet21.Clear();
// 将记录合并到主数据集中。
dataSet21.Merge(objDataSetTemp);
}
catch (System.Exception eLoadMerge) {
// 在此处添加错误处理代码。
throw eLoadMerge;
}
}
#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.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.dataSet21 = new ltq.DataSet2();
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).BeginInit();
//
// oleDbDataAdapter1
//
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "1999", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("学号", "学号"),
new System.Data.Common.DataColumnMapping("科目", "科目"),
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 "+Request.QueryString["xuehao"].Substring(0,4)+" where 学号='"+Request.QueryString["xuehao"]+"'";
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=Read;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";
//
// dataSet21
//
this.dataSet21.DataSetName = "DataSet2";
this.dataSet21.Locale = new System.Globalization.CultureInfo("en-US");
this.dataSet21.Namespace = "http://tempuri.org/DataSet2.xsd";
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
try {
this.LoadDataSet();
this.DataGrid1.SelectedIndex = -1;
this.DataGrid1.DataBind();
}
catch (System.Exception eLoad) {
this.Response.Write(eLoad.Message);
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -