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