收藏 分享(赏)

跳转检索传值.doc

上传人:buyk185 文档编号:6988191 上传时间:2019-04-29 格式:DOC 页数:4 大小:50.50KB
下载 相关 举报
跳转检索传值.doc_第1页
第1页 / 共4页
跳转检索传值.doc_第2页
第2页 / 共4页
跳转检索传值.doc_第3页
第3页 / 共4页
跳转检索传值.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、public class UserInfoprivate string userName;private string passWord;private string xingMing;private string age;public string UserNameget return userName; set userName = value; public string PassWordget return passWord; set passWord = value; public string XingMingget return xingMing; set xingMing =

2、value; public string Ageget return age; set age = value; public class DBHelperprivate static string connectionString = “Server=I6R7IVUNHOKLYSD;Database= DBUser;Trusted_connection=SSPI“;public static SqlDataReader ExecuteReader(string strSql)SqlConnection con = new SqlConnection(connectionString);Sql

3、Command cmd = new SqlCommand(strSql, con);trycon.Open();SqlDataReader myReader = cmd. ExecuteReader(CommandBehavior.CloseConnection);return myReader;catch (System.Data.SqlClient.SqlException e)throw e;public static DataSet Query(string SQLString)using (SqlConnection connection = new SqlConnection(co

4、nnectionString)DataSet ds = new DataSet();tryconnection.Open();SqlDataAdapter command = new SqlDataAdapter(SQLString, connection);command.Fill(ds, “ds“);catch (System.Data.SqlClient.SqlException ex)throw new Exception(ex.Message);return ds;public partial class Login : System.Web.UI.Pageprotected voi

5、d Page_Load(object sender, EventArgs e)lblTishi.Text = string.Empty;protected void btnOk_Click(object sender, EventArgs e)string sql = string.Format(“select * from UserInfo where UserName=0 and PassWord=1“, txtName.Text, txtMm.Text);UserInfo us = getUser(sql);if (us != null)Session“user“ = us;Respon

6、se.Redirect(“Main.aspx“);elselblTishi.Text = “用户名或密码出错“;protected UserInfo getUser(string sql)UserInfo us = null;SqlDataReader myReader = DBHelper.ExecuteReader(sql);if (myReader.Read()us = new UserInfo();us.UserName = myReader“UserName“.ToString();us.PassWord = myReader“PassWord“.ToString();us.Xing

7、Ming = myReader“XingMing“.ToString();us.Age = myReader“Age“.ToString();return us;protected void btnClear_Click(object sender, EventArgs e)txtName.Text = string.Empty;txtMm.Text = string.Empty;public partial class Main : System.Web.UI.Pageprotected void Page_Load(object sender, EventArgs e)if (Sessio

8、n“user“ != null)UserInfo us = (UserInfo)Session“user“;lblMessage.Text = us.XingMing;elseResponse.Redirect(“Login.aspx“);protected void btnOut_Click(object sender, EventArgs e)Response.Redirect(“Login.aspx“);public partial class UserInform : System.Web.UI.Pageprotected void Page_Load(object sender, E

9、ventArgs e)if(!IsPostBack)string sql=string.Format(“select * from UserInfo order by sort“);bindDataGridView(sql);protected void btnRet_Click(object sender, EventArgs e)string sql=string.Format(“select * from UserInfo where XingMing like %0%“,txtName.Text.Trim();bindDataGridView(sql);protected void bindDataGridView(string sql)DataTable dt=DBHelper.Query(sql).Tables0;if(dt!=nullGridView1.DataBind();

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报