欢迎来到天天文库
浏览记录
ID:21330525
大小:50.50 KB
页数:4页
时间:2018-10-21
《跳转检索传值》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、publicclassUserInfo{privatestringuserName;privatestringpassWord;privatestringxingMing;privatestringage;publicstringUserName{get{returnuserName;}set{userName=value;}}publicstringPassWord{get{returnpassWord;}set{passWord=value;}}publicstringXingMing{get{returnxingMing;}set{xingMing=value;}}pub
2、licstringAge{get{returnage;}set{age=value;}}}publicclassDBHelper{privatestaticstringconnectionString=@"Server=I6R7IVUNHOKLYSD;Database=DBUser;Trusted_connection=SSPI";publicstaticSqlDataReaderExecuteReader(stringstrSql){SqlConnectioncon=newSqlConnection(connectionString);SqlCommandcmd=newSql
3、Command(strSql,con);try{con.Open();SqlDataReadermyReader=cmd.ExecuteReader(CommandBehavior.CloseConnection);returnmyReader;}catch(System.Data.SqlClient.SqlExceptione){throwe;}}publicstaticDataSetQuery(stringSQLString){using(SqlConnectionconnection=newSqlConnection(connectionString)){DataSetd
4、s=newDataSet();try{connection.Open();SqlDataAdaptercommand=newSqlDataAdapter(SQLString,connection);command.Fill(ds,"ds");}catch(System.Data.SqlClient.SqlExceptionex){thrownewException(ex.Message);}returnds;}}}publicpartialclassLogin:System.Web.UI.Page{protectedvoidPage_Load(objectsender,Even
5、tArgse){lblTishi.Text=string.Empty;}protectedvoidbtnOk_Click(objectsender,EventArgse){stringsql=string.Format("select*fromUserInfowhereUserName='{0}'andPassWord='{1}'",txtName.Text,txtMm.Text);UserInfous=getUser(sql);if(us!=null){Session["user"]=us;Response.Redirect("Main.aspx");}else{lblTis
6、hi.Text="用户名或密码出错";}}protectedUserInfogetUser(stringsql){UserInfous=null;SqlDataReadermyReader=DBHelper.ExecuteReader(sql);if(myReader.Read()){us=newUserInfo();us.UserName=myReader["UserName"].ToString();us.PassWord=myReader["PassWord"].ToString();us.XingMing=myReader["XingMing"].ToString();
7、us.Age=myReader["Age"].ToString();}returnus;}protectedvoidbtnClear_Click(objectsender,EventArgse){txtName.Text=string.Empty;txtMm.Text=string.Empty;}}publicpartialclassMain:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(Sessi
此文档下载收益归作者所有