資源描述:
《.net 登錄注冊參考代碼》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、登錄usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Xml.Linq;usingSystem.Data.SqlClient;usingSystem.Data;publicpartialclass_Default:System.Web.UI.Page{protectedvoidPage_Load
2、(objectsender,EventArgse){}protectedvoidButton1_Click(objectsender,EventArgse){stringconnectionString=@"DataSource=.SQLEXPRESS;AttachDbFilename=C:UserslenovoDesktop王a?曉t玲¢¨¢App_DataDatabase.mdf;IntegratedSecurity=True;UserInstance=True";//創(chuàng)???建?§獲?取¨?數(shù)oy據(jù)
3、Y庫a連¢?接¨?字á?符¤?串??,ê?并?é創(chuàng)???建?§數(shù)oy據(jù)Y庫a連¢?接¨?對?象¨?stringsql="selectusername,passwordfromT1whereusername='"+TextBox1.Text+"'andpassword='"+TextBox2.Text+"'";SqlConnectionconn=newSqlConnection(connectionString);//實(shí)o|ì例¤y化?¥連¢?接¨?對?象¨?SqlCommandcmd=newSqlCommand(sql
4、,conn);//執(zhí)??行D命¨1令¢?conn.Open();//打?¨°開a數(shù)oy據(jù)Y庫aSqlDataReaderr=cmd.ExecuteReader();if(r.Read())//從?¨?數(shù)oy據(jù)Y庫a讀¨¢取¨?用??戶?ì信?息?é,判D斷?是o?否¤?有?D記?錄?{Response.Write("");//Response.Redirect("Text.aspx");}else{//if(username.Trim()!
6、=TextBox1.Text
7、
8、password.Trim()!=TextBox2.Text)//判D斷?用??戶?ì名?密¨1碼?是o?否¤?一°?致?{Response.Write("");//Label5.Text="用??戶?ì名?或¨°密¨1碼?錯(cuò)?¨a誤¨?,請?重?新?輸o?入¨?";//Response.Redirect("login.aspx");}}//else//{//Respon
9、se.Write("");//}}protectedvoidButton2_Click(objectsender,EventArgse){Response.Redirect("Register.aspx");//轉(zhuǎn)áa到ì?注á?é冊¨¢頁°3}}注冊usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.We
10、b.UI;usingSystem.Web.UI.WebControls;usingSystem.Xml.Linq;usingSystem.Data.SqlClient;usingSystem.Data;usingSystem.Collections;usingSystem.Configuration;usingSystem.Web.UI.HtmlControls;usingSystem.Web.UI.WebControls.WebParts;publicpartialclassDefault3:System.Web.U
11、I.Page{protectedvoidPage_Load(objectsender,EventArgse){}protectedvoidButton1_Click(objectsender,EventArgse){if(TextBox4.Text==String.Empty){Label4.Text="請?輸o?入¨?內(nèi)¨2容¨