Difference between executenonquery executescalar executereader in c#

random

Difference between executenonquery executescalar executereader in c#

When to use Executereader Executenonquery Executescalar?

In this blog post I will explain about Ado.Net SqlCommands  and what is the difference between executereader executenonquery and executescalar. 
  • ExecuteNonQuery in C#
ExecuteNonQuery method will return number of rows effected with CRUD (INSERT, DELETE or UPDATE) operations. This ExecuteNonQuery method will be used only for insert, update and delete, create, and set statements.
  • ExecuteReader in C#
ExecuteReader will be used to return the set of rows, on execution of SQL Query/Stored procedure using command object. This one is forward only retrieval of records and it is used to read the table values from first to last.
  • ExecuteScalar in C#
ExecuteScalar will return single row single column value i.e. single value, on execution of SQL Query or Stored procedure using command object. It’s very fast to retrieve single values from database.

I hope you have enjoyed the article on commandtype c#, executenonquery in c#,executenonquery c#, c# sqldatareader. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.
Difference between executenonquery executescalar executereader in c# Reviewed by Ravi Kumar on 10:45 PM Rating: 5

No comments:

All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form

Name

Email *

Message *

Powered by Blogger.