User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 360,995 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,426 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 5993 | Replies: 2
Reply
Join Date: Mar 2006
Posts: 11
Reputation: rajni11 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
rajni11 rajni11 is offline Offline
Newbie Poster

ExecuteRedear vs ExecuteScalar

  #1  
May 8th, 2006
I am having confusion in ExecuteScalar & ExecuteReader



If we use ExecuteReader for select with aggregate function, it will not give any error and run successfully so if we can do both queries select with aggregate & select with non aggregate with the help of only one method ExecuteReader so why is there ExecuteScalar………, is there any other benefit of it?



Please give the proper answer
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: ExecuteRedear vs ExecuteScalar

  #2  
May 10th, 2006
The main difference is the "footprint" of the return value. ExecuteReader always returns an object, for example, a SqlDataReader. Then, to get the actual results, you have to do a Read(), then get the value.

ExecuteScalar immediately returns the actual value.

So, in terms of retrieving Scalar data from a database, ExecuteScalar is more efficient.
Reply With Quote  
Join Date: Mar 2006
Posts: 11
Reputation: rajni11 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
rajni11 rajni11 is offline Offline
Newbie Poster

Re: ExecuteRedear vs ExecuteScalar

  #3  
May 11th, 2006
Thanx......




Originally Posted by tgreer
The main difference is the "footprint" of the return value. ExecuteReader always returns an object, for example, a SqlDataReader. Then, to get the actual results, you have to do a Read(), then get the value.

ExecuteScalar immediately returns the actual value.

So, in terms of retrieving Scalar data from a database, ExecuteScalar is more efficient.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 6:47 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC