ado.not--change a refinement exercise

Source: Internet
Author: User

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 usingSystem.Data.SqlClient;7 8 namespace_06_229 {Ten     class Program One     { A         Static voidMain (string[] args) -         { -  the             //Practice Questions: -  -             #regionShow All -             //1, Car table data isolated display +SqlConnection Coon =NewSqlConnection ("server=.; database=data0425;user=sa;pwd=123;"); -SqlCommand com =Coon. CreateCommand (); +  ACom.commandtext ="SELECT * FROM car"; at Coon. Open (); -SqlDataReader A1 =com. ExecuteReader (); -             if(A1. HasRows) -             { -                  while(A1. Read ()) -                 { inConsole.WriteLine ("Number:"+ a1["Code"] +"Brand:"+ a1["name"] +"Fuel consumption:"+ a1[" Oil"] +"Horsepower:"+ a1["Powers"] +"Displacement:"+ a1["Exhaust"] +"Price:"+ a1[" Price"]); -                 } to             } +  - Coon. Close (); the             #endregion *  $             //2, please enter the name of the car to check:Panax Notoginseng             //Please enter the vehicle fuel consumption to be checked: -             //Please enter the car horsepower to check: the             //Name: BMW +             //fuel consumption: 8 A             //Horsepower: 1 the  +  -  $              for (; ; ) $             { -Console.Write ("Please enter the name of the car you want to check:"); -                 stringCNAME =console.readline (); theConsole.Write ("Please enter the vehicle fuel consumption to be checked:"); -                 stringCoil =console.readline ();WuyiConsole.Write ("Please enter the car horsepower to check:"); the                 stringCpowers = Console.ReadLine ();//Enter Query content -  Wu  -Com.commandtext ="SELECT * from car where name is @cname and oil like @coil and powers like @cpowers"; About  $ com. Parameters.clear (); -Com. Parameters.Add ("@cname","%"+ CNAME +"%"); -Com. Parameters.Add ("@coil","%"+ Coil +"%"); -Com. Parameters.Add ("@cpowers","%"+ Cpowers +"%"); A  + Coon. Open (); theSqlDataReader C1 =com. ExecuteReader (); -                     if(C1. HasRows) $                     { the                          while(C1. Read ()) the                         { theConsole.WriteLine ("Number:"+ c1["Code"] +"Brand:"+ c1["name"] +"Fuel consumption:"+ c1[" Oil"] +"Horsepower:"+ c1["Powers"] +"Displacement:"+ c1["Exhaust"] +"Price:"+ c1[" Price"]); the                         } -Console.Write ("is it over? [y/n]"); in                         stringJS =console.readline (); the                         if(js = ="y") the{ Break; } About                     } the                     Else the{Console.WriteLine ("Do not check this!!! Re-enter!! "); } the Coon. Close (); +           -  the Bayi  the  the             } - console.readline (); -         } the     } the}

ado.not--change a refinement exercise

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.