Showing posts with label ExecuteReader and ExecuteNonQuery. Show all posts
Showing posts with label ExecuteReader and ExecuteNonQuery. Show all posts

Sunday, 19 July 2015

Differnce between ExecuteScalar, ExecuteReader and ExecuteNonQuery

Today we are going discuss most common doubts among DotNetDevelopers.
Differnce between ExecuteScalar, ExecuteReader and ExecuteNonQuery

ExecuteScalar is going to be the type of query which will be returning a single value. An example would be selecting a count of the number of active users.

ExecuteReader gives you a data reader back which will allow you to read all of the columns of the results a row at a time. An example would be getting all of the information for each user in the system so you could display that information.

ExecuteNonQuery is any SQL which isn't returning values really, but is actually performing some form of work like inserting deleting or modifying something. An example would be updating a user's personal information in the database.
Summary
In this article I try to clear difference between ExecuteSaclar, ExecuteReader and Execute NonQuery I hope after reading this article you will be able to use this trick in your code. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.