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

📄 duzhexinxi.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.SqlClient;
namespace mybook
{
	/// <summary>
	/// duzhexinxi 的摘要说明。
	/// </summary>
	public class duzhexinxi : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.TextBox TextBox2;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.Label Label1;
	
		private 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.TextBox1.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.TextBox2.TextChanged += new System.EventHandler(this.TextBox2_TextChanged);
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{
			string message=this.show();
			TextBox2.Text=message;
		}

		public SqlConnection connection()   //设置数据库连接
		{
			string Afile="server=.;uid=sa;pwd=sa;database=mybook";		
			SqlConnection AconnStr=new SqlConnection(Afile);
			return AconnStr;
		}
		public void close(SqlConnection AconnStr)//关闭连接
		{
			AconnStr.Close();
		}
		public SqlDataReader selCommand(string comd,SqlConnection AconnStr) //设置数据库查询操作命令
		{
			SqlCommand Acmd=new SqlCommand(comd,AconnStr);
			SqlDataReader sdr=null;
			AconnStr.Open();
			try
			{
				//执行命令,获取数据流
				sdr=Acmd.ExecuteReader();
				return sdr;
			}
			catch(Exception e)
			{
				if(e!=null)
				{
					Console.Write("执行出错");				
				}	
				return null;		
			}
		
		}

		public string show()
		{
			SqlConnection scon=this.connection();
			string select="select * from SELJS" +
				" WHERE tushuno = '" + TextBox1.Text+"'"; 


//Response.Write(select);




			SqlDataReader sdr=this.selCommand(select,scon);
			string info="";
			if(sdr!=null)
			{
				//按记录顺序使用数据流
				
			
				while(sdr.Read())
				{
			
					info+=sdr["name"].ToString()+"\t";
					info+=sdr["stuno"].ToString()+"\t\t";
					info+=sdr["xibie"].ToString()+"\t";
				
				
					info+=sdr["tushuno"].ToString()+"\t";
					info+=sdr["tushuname"].ToString()+"\t";
					info+=sdr["jieshuriqi"].ToString()+"\t\t";
					info+=sdr["huanshuriqi"].ToString()+"\t\t";
				

					
				}
				sdr.Close();  //关闭数据流
			}
			return info;
			
		}

		private void TextBox2_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void TextBox1_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void Button2_Click(object sender, System.EventArgs e)
		{
		Response.Redirect("commonselect.aspx");
		}

		
		
	}
}

⌨️ 快捷键说明

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