DataAdaper.Fill question

  • Thread starter Thread starter Hardy Wang
  • Start date Start date
H

Hardy Wang

Hi all, with the sample below, if the query returns huge amount of data,
will database returns the portion required by program or returns all data,
then Fill methods filter unnecessary ones?

int currentIndex = 0;
int pageSize = 5;

string orderSQL = "SELECT * FROM Orders ORDER BY OrderID";
SqlDataAdapter myDA = new SqlDataAdapter(orderSQL, nwindConn);

DataSet myDS = new DataSet();
myDA.Fill(myDS, currentIndex, pageSize, "Orders");
 
Basically (as described in this article
http://www.vbdotnetheaven.com/Code/Sept2003/2173.asp) the Fill method with
this overload executes a query that limits the number of rowset members.
Using an appropriate index, the Fill method can be used to "page" through
the server rows that qualify (based on the WHERE clause) starting at a
specific point (what you're calling "currentIndex"). No, the engine does not
return all the rows and have ADO subsequently filter them.

In any case, it's interesting (and educational) to use the SQL Profiler to
watch what SQL Server is being asked to do when you execute any ADO method.
I show how to do this in my book(s).

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top