Ashish Kumar Singh
Explain the use of ExecuteNonQuery, ExecuteReader, ExecuteScalar?
Posted by Ashish Kumar Singh in .Net | ASP.NET on Oct 01, 2012
  • 0
  • 4
  • 2478
Do you know the answer for this question? Post it below.
Guest
Posted by Vithal Wadje on Oct 05, 2012
  • 2

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.

Posted by Vithal Wadje on Oct 05, 2012
  • 1

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.

Posted by Vithal Wadje on Oct 05, 2012
  • 1

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();

Posted by kiran kumar on Feb 04, 2013
  • 0

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.


Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter
PRIVACY POLICY | TERMS & CONDITIONS | SITEMAP | CONTACT US | ABOUT US | REPORT ABUSE
2013© C# Corner. All contents are copyright of their authors.