ADO Database Modification

Source: Internet
Author: User

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

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.