Well, you could modify your stored procedure to look like this:

set rowcount = @rows
select * from SomeTable
set rowcount = 0

Where @rows is a parameter that is passed into the procedure...or if you
only want one, just hard code it.

My understanding is that 'set rowcount' is more efficient than 'top', but
I'm just now wading into Inside SQL Server 2000 (great book) and it hasn't
been covered yet...

Seang

-----Original Message-----
From: Andreas Håkansson [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 14, 2002 4:31 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Performence of SqlDataAdapter.Fill


I'm currently writing a class that acts as a collection
that sits ontop of a database, i.e it fetches the data
from the database when it's requested.

I'm adding an indexer to my class to get item x, which
also means row x in the query result. What I'm doing
now is use a SqlCommand setup to call my stored procedure
and then I set the SelectCommand property of the
SqlDataAdapter and do something like this


public object this[int index]
{
        get
        {
                // Set up my SqlCommand to call my sp
                SqlDataAdapter myAdapter = new SqlDataAdapter();
                myAdapter.SelectCommand = myCommand;
                DataSet myDataSet = new DataSet();
                myAdapter.Fill(myDataSet, index, 1, "results");

                // create an object and populate it with the
                // results..then return it..
                return newObject;
        }
}

What I'm concerned with is if the overload of the Fill
method actually gets the entire resultset and then grabs
the row I asked, thus transfering the entire result into
my app which means a waste of network traffic. If so, then
are there any better ways of doing this?


--
Andreas Håkansson
Student of Software Engineering
andreas (at) selfinflicted.org

In a world in which we are all slaves to the laws of gravity,
I'm proud to be counted as one of the freedom fighters.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to