The Code worth Learning 1

Source: Internet
Author: User

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingsystem.web;5 usingSystem.Web.UI;6 usingSystem.Web.UI.WebControls;7 usingSystem.Text;8 usingSystem.Configuration;9 usingSystem.Data.SqlClient;Ten namespacevip20160413 One { A      Public Partial classUserInfo:System.Web.UI.Page -     { -         Private stringSCon = configurationmanager.connectionstrings["Sq_ruanmou"]. ToString ();//get to the link string by a node named Sq_ruanmou theSqlConnection con =NULL;//con equals the phone . -SqlCommand cmd =NULL;//that is used to execute the SQL statement. -SqlDataReader Read =NULL;//for storing query structures -         Private voidopendb () +         { -Con =NewSqlConnection (sCon); +Con. Open ();//and the database was established connected A         } at         Private int_userid =0; -  -          Public intUserId -         { -             Get { -                 Try in                 { -_userid = request.querystring["UserId"] ==NULL?0: Convert.ToInt32 (request.querystring["UserId"]. ToString ()); to                 } +                 Catch { -_userid =0; the                 } *                 return_userid; $             }Panax Notoginseng             Set{_userid =value;} -         } the         protected voidPage_Load (Objectsender, EventArgs e) +         { A  the         } +          Public stringgetuserinforhtml () -         { $StringBuilder SB =NewStringBuilder (); $             if(UserId >0) -             { -Sb. Append (@"<div class= "Das" >"); theSb. Append ("<table>"); - opendb ();Wuyi                 stringsSQL =string. Format ("SELECT * from Userinfor where userid={0}", UserId); the                 using(cmd =NewSqlCommand (sSQL, con)) -                 { Wu                     using(read =cmd. ExecuteReader ()) -                     { About                         if(read. Read ()) $                         { -Sb. Append (string. Format ("<tr><td> user name:</td><td>{0}</td></tr>", read["UserName"]. ToString ())); -Sb. Append (string. Format ("<tr><td> Password:</td><td>{0}</td></tr>", read["PWD"]. ToString ())); -Sb. Append (string. Format ("<tr><td>QQ:</td><td>{0}</td></tr>", read["QQ"]. ToString ())); ASb. Append (string. Format ("<tr><td> class:</td><td>{0}</td></tr>", read["Phase"]. ToString ())); +Sb. Append (string. Format ("<tr><td> Mobile number:</td><td>{0}</td></tr>", read["Phonenum"]. ToString ())); theSb. Append (string. Format ("<tr><td> name:</td><td>{0}</td></tr>", read["Realname"]. ToString ())); -                         } $                     } the                 } theSb. Append ("</table>"); theSb. Append (@"</div>"); the             } -             returnsb. ToString (); in         } the     } the}

The Code worth Learning 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.