These are the methods under Command Object
ExecuteReader : Used to execute SQL Select Command
ExecuteScalar : Used to execute SQL Select command which is used to return a single value. Example the group function output
ExecuteNonQuery : USed to execute SQL Insert, Delete and Update Commands.
ExecuteScalar returns only one value after execution of the query . it returns the first field in the first row. it is faster and convinient way when you wants rerive only single value at a time.
this method returns a DataReader which is filled with the data that is retrived using the coommand object . this is known as a forward only retrival of records.
ExecuteNonQuery does not return any data at all. it is used basically to insert update operationas on table. means it is used for execution of DML commands
sqlcommand cmd=new sqlCommand("insert into emp values ('1','2'",con);
2016© C# Corner. All contents are copyright of their authors.
C# Corner. All contents are copyright of their authors.