CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Posts
    97

    SqlDataAdapter .Fill() using DataTable instead of DataSet?


    string m_sSelect = "SELECT Firstname, Secondname, [House Name], [House No], Street, Area, Postcode FROM VOTERSREGISTER WHERE [Postcode] = 'DUBLIN 6W'";

    int m_nCurrentRow = 0;
    ...
    ...
    ...

    public bool Read(ref DataSet ds)
    {
    SqlDataAdapter m_sda = new SqlDataAdapter(m_sSelect, m_sqlcConn);

    ds.Clear();
    try
    {
    m_sda.Fill(ds, m_nCurrentRow, 100, "VotingRegister");
    }
    catch(ERROR BLA DI BLA....)
    {
    return false;
    }

    if(0 == ds.Tables["VotingRegister"].Rows.Count)
    return false;

    m_nCurrentRow += 100;

    return true;
    }


    This is the my code.

    Now my problem is that I am using a DataSet to hold the return data and I place that data in a Table called VotingRegister. I feel thats a bit of a waste. Is there anyway that just insert the data into a DataTable? Also see the way I pull in 100 rows at a time. Is it possible to do the same with .Fill() if you use a DataTable? As I'm expect over 5000 records to be returned if I didn't do it in steps.

    help please!

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    look in the 5'th parameter of Fill method !!

    Paresh
    - Software Architect

  3. #3
    Join Date
    Mar 2003
    Posts
    97
    I gather your on about this one...

    [C#]
    protected virtual int Fill(
    DataTable dataTable,
    IDbCommand command,
    CommandBehavior behavior
    );

    but what I don't understand is how do you get it to read in 100 rows at a time. Say If I have 1000 rows in a database. I only want 100 at a time. I read in the first 100, I read in the second 100 but need to read from row 200. how you do that?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured