Database modification methods and additions, just replace the increment statement with the modified statement, after the execution of the statement is the same
The first is what data you need to get and receive input to modify, and the modified data
Code Demo:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Data.SqlClient;//refer to the database first, this step can not forgetnamespaceado.net_ Database Modification {classProgram {Static voidMain (string[] args) { //Modify the database information, also need to receive the modified information, and then perform the modificationConsole.Write ("Please enter the student number to be modified:"); stringZcode =Console.ReadLine (); Console.Write ("Please enter the name of the student after the change:"); stringZname =Console.ReadLine (); Console.Write ("Please enter the modified student's gender:"); BOOLZsex =Convert.toboolean (Console.ReadLine ()); Console.Write ("Please enter the revised student's birthday:"); DateTime Zbirth=Convert.todatetime (Console.ReadLine ()); Console.Write ("Please enter the revised student score:"); decimalZscore =Convert.todecimal (Console.ReadLine ()); SqlConnection Conn=NewSqlConnection ("server=.; database=adonet;user=sa;pwd=123;"); SqlCommand CMM=Conn. CreateCommand (); //Connection statement, this method is to write an SQL statementCmm.commandtext ="update xue set name= '"+ Zname +"', sex= '"+ Zsex +"', birth= '"+ Zbirth +"', chengji="+ zscore+"where code= '"+zcode+"'"; Conn. Open (); Cmm. ExecuteNonQuery ();//executes the method, executes the written SQL statementConsole.WriteLine ("modified successfully! "); Conn. Close (); Console.ReadLine (); } }}
ADO Database Modification