Home > Net >  For help using Command objects correspond to tables of database studentDB student inserting a record
For help using Command objects correspond to tables of database studentDB student inserting a record

Time:11-25

Using studentDB Command objects to realize the corresponding database table student to insert a record, the name is "zhang", is a "male", the city as the "wuhan", called sqlCon (server)

CodePudding user response:

The book example has the answer

CodePudding user response:

 
//probably is such a process
SqlConnection conn=new SqlConnection (" Server=sqlCon; Initial Catalog=studentDB; UID=XXX; The PWD=XXX ");//XXX login database user name and password for you
SqlCommand CMD=new SqlCommand (" insert into student (Name, Gender, City) values (' zhang 'and' male ', 'wuhan) ", conn);//the Name, Gender, City, see you how table structure field
Conn. The Open ();
CMD. ExecuteNonQuery ();
Conn. Close ();

CodePudding user response:

To view the code ado.net
https://docs.microsoft.com/zh-cn/dotnet/framework/data/adonet/updating-data-in-a-data-source
  • Related