📄 zhanghu.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;
using System.Data.SqlClient;
namespace nicholasbjj
{
/// <summary>
/// Summary description for zhanghu.
/// </summary>
public class zhanghu : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.DataGrid DGyonghu;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.HyperLink HyperLink2;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
string sql="select * from [yonghugl]";
string strConn="Server=(local);User ID=sa;Database=bjj;PassWord=temo456";
SqlConnection conn=new SqlConnection(strConn);
SqlCommand cmd=new SqlCommand();
SqlDataReader reader;
cmd.Connection=conn;
cmd.CommandText=sql;
conn.Open();
reader=cmd.ExecuteReader();
DGyonghu.DataSource=reader;
DGyonghu.DataBind();
reader.Close();
conn.Close();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </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)
{
//SELECT username AS 用户名, comname AS 所属电厂, admin AS 用户权限, phone, email, qq AS QQ帐号, address AS 家庭住址 FROM dbo.[user]}
try
{
string sql="SELECT dbo.[user].username AS 用户名, dbo.[user].comname AS 所属电厂, dbo.[user].admin AS 用户权限, dbo.[user].phone AS 电话号码, dbo.[user].email AS 电子邮箱,";
sql+=" dbo.[user].qq AS QQ帐号, dbo.[user].address AS 家庭住址";
sql+=" from dbo.[user]";
sql+=" where username='" + TextBox1.Text +"'";
string strConn="Server=(local);User ID=sa;Database=bjj;PassWord=temo456";
SqlConnection conn=new SqlConnection(strConn);
SqlCommand cmd=new SqlCommand();
SqlDataReader reader;
cmd.Connection=conn;
cmd.CommandText=sql;
conn.Open();
reader=cmd.ExecuteReader();
DGyonghu.DataSource=reader;
DGyonghu.DataBind();
conn.Close();
}
catch
{
Response.Write("查找失败!");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -