RE: Best way to return a select number of rows?

From: Kevin Yu [MSFT] (v-kevy_at_online.microsoft.com)
Date: 02/13/04


Date: Fri, 13 Feb 2004 09:22:10 GMT

Hi Jeff,

Thank you for posting in the community!

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get certain number of
records from the server begin with certain index. If there is anything
unclear, please feel free to let me know.

Generally, we can achieve this in two ways.

1. We can do this on the server side. We can modify the stored procedure to
make it return the result set which only contains the specified records.
This is fast, because all the jobs are done on the server side. However, as
you mentioned this is quite complicated and has to make one for each query.

2. There is an overload in SqlDataAdapter.Fill method public int
Fill(DataSet dataSet, int startRecord, int maxRecords, string srcTable);
This overload can fill a certain number of result set into DataSet from a
start index. I think this might match your requirement. However, it might
be a little slower than the first method. Here I write a code snippet for
paging:

        private DataSet GetPagedRecords(int page)
        {
                const int iNum = 9;
                int iStart = (page - 1) * iNum;
                DataSet ds = new DataSet();
                this.sqlDataAdapter1.Fill(ds, iStart, iNum, "Table1");
                return ds;
        }

Hope this helps. Does this answer your question? If anything is unclear,
please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."



Relevant Pages

  • SSPI Kerberos for delegation
    ... security context created in server to connect back and authenticate to ... DWORD bufsiz = sizeof buf; ... int n = ib.cbBuffer; ... // wserr() displays winsock errors and aborts. ...
    (microsoft.public.win32.programmer.kernel)
  • SSPI delegation using kerberos
    ... security context created in server to connect back and authenticate to ... DWORD bufsiz = sizeof buf; ... int n = ib.cbBuffer; ... // wserr() displays winsock errors and aborts. ...
    (microsoft.public.platformsdk.security)
  • SSPI Kerberos for delegation
    ... security context created in server to connect back and authenticate to ... DWORD bufsiz = sizeof buf; ... int n = ib.cbBuffer; ... // wserr() displays winsock errors and aborts. ...
    (microsoft.public.platformsdk.security)
  • SSPI Kerberos for delegation
    ... security context created in server to connect back and authenticate to ... DWORD bufsiz = sizeof buf; ... int n = ib.cbBuffer; ... // wserr() displays winsock errors and aborts. ...
    (microsoft.public.security)
  • [2.6 patch] remove smbfs
    ... smbfs back in 2005 due to smbfs being unmaintained. ... for mounting to older SMB servers such as OS/2. ... -that turns any Unix host into a file server for DOS or Windows clients. ... -static int do_smb_getmountuid ...
    (Linux-Kernel)