ADO Property Extension

Source: Internet
Author: User

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingproperty extension. Model;usingproperty extension. dataoperation;namespaceProperty Extension {classProgram {Static voidMain (string[] args) {List<Score> list =NewScoredata ().            SelectAll (); foreach(Score Sinchlist) {Console.WriteLine (S.sno+"  "+ S.sname +"  "+ S.ssex +"  "+ S.cno +"  "+ S.cnoname +"  "+s.degree);        } console.readkey (); }    }}
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingproperty extension. Model;usingSystem.Data.SqlClient;namespaceproperty extension. dataoperation{ Public classScoredata {SqlConnection conn=NULL; SqlCommand cmd=NULL;  PublicScoredata () {conn=NewSqlConnection ("server=.; Database=data05152;user=sa;pwd=123"); CMD=Conn.        CreateCommand (); }         PublicList<score>SelectAll () {List<Score> list =NewList<score>(); Cmd.commandtext="Select *from Score"; Conn.            Open (); SqlDataReader Dr=cmd.            ExecuteReader (); if(Dr. HasRows) { while(Dr. Read ()) {score S=Newscore (); S.cno= dr["CNO"].                    ToString (); S.sno= Convert.ToInt32 (dr["Sno"]); S.degree= Convert.todecimal (dr["degree"]); List.                ADD (s); }} conn.            Close (); returnlist; }    }}
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Data.SqlClient;namespaceproperty extension. model{ Public classScore {Private int_sno;  Public intSno {Get{return_sno;} Set{_sno =value;} }        Private string_cno;  Public stringCno {Get{return_cno;} Set{_cno =value;} }         Public stringCnoname {Get            {                stringn =""; SqlConnection Conn=NewSqlConnection ("server=.; Database=data05152;user=sa;pwd=123"); SqlCommand cmd=Conn.                CreateCommand (); Cmd.commandtext="Select *from Course where CNO = @cno"; Cmd.                Parameters.clear (); Cmd. Parameters.Add ("@cno", _CNO); Conn.                Open (); SqlDataReader Dr=cmd.                ExecuteReader (); if(Dr. HasRows) { while(Dr. Read ()) {n= dr["CNAME"].                    ToString (); }} conn.                Close (); returnN; }        }        Private decimal_degree;  Public decimalDegree {Get{return_degree;} Set{_degree =value;} }         Public stringSname {Get            {                stringn =""; SqlConnection Conn=NewSqlConnection ("server=.; Database=data05152;user=sa;pwd=123"); SqlCommand cmd=Conn.                CreateCommand (); Cmd.commandtext="Select *from Student where sno = @sno"; Cmd.                Parameters.clear (); Cmd. Parameters.Add ("@sno", _sno); Conn.                Open (); SqlDataReader Dr=cmd.                ExecuteReader (); if(Dr. HasRows) { while(Dr. Read ()) {n= dr["sname"].                    ToString (); }} conn.                Close (); returnN; }        }         Public stringSsex {Get            {                stringn =""; SqlConnection Conn=NewSqlConnection ("server=.; Database=data05152;user=sa;pwd=123"); SqlCommand cmd=Conn.                CreateCommand (); Cmd.commandtext="Select *from Student where sno = @sno"; Cmd.                Parameters.clear (); Cmd. Parameters.Add ("@sno", _sno); Conn.                Open (); SqlDataReader Dr=cmd.                ExecuteReader (); if(Dr. HasRows) { while(Dr. Read ()) {n= dr["Ssex"].                    ToString (); }} conn.                Close (); returnN; }        }    }}

ADO Property Extension

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.