Monday 6 May 2013

What is the differance between execute scalar, execute reader or execute non query in asp.net?

ExecuteScalar-- 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.

ExecuteReader- 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- 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 e.g sqlcommand cmd=new sqlCommand("insert into emp values ('1','2'",con); con.open(); cmd.ExecuteNonquery();

For brief Tutorial visit http://www.raaas.com

No comments:

Post a Comment