Click to See Complete Forum and Search --> : SqlDataAdapter .Fill() using DataTable instead of DataSet?


zoltan_ie
April 16th, 2003, 12:19 PM
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!

pareshgh
April 16th, 2003, 12:23 PM
look in the 5'th parameter of Fill method !!

Paresh

zoltan_ie
April 17th, 2003, 03:51 AM
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?