SqlDataReader Limitation?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

Is there a limitation on how many rows can be fetched using a SqlDataReader
in ASP.Net 2.0 ?
 
Well, you can only read one at a time, which I assume is that the previous
poster was talking about...

But there's no built-in limitation. I imagine if you tried to receive a
billion rows something would go wrong. The real limitation is going to be
what you are storing the data into. I mean, if you discard the data via
something like:

while (dr.Read())
{
}

I imagine you could fetch an unlimited number of rows...


but if you are loading the data into something, like:

while(dr.Read())
{
users.Add(new User.CreateNewUser(dr));
}

you'll obviously eventually run out of memory because your user collection
is going to grow to be too much.

Karl
 
Thanks. Yes I am doing something like...

while (myReader.Read())
{
dr = dt.NewRow();
dr["fullname"] = Convert.ToString(myReader.GetValue(2));
dr["dob"] =
Convert.ToString(Convert.ToDateTime(myReader.GetValue(3)).ToShortDateString());
dr["description"] = Convert.ToString(myReader.GetValue(4));
dt.Rows.Add(dr);
}

Then,
GridView1.datasource=dt//dt is the datatable
GridView.DataBind().

I am seeing that my GridView doesn't show all the rows that have been
returned from the sql query...
How do I achieve this ?

Thanks

--
Thanks,
SDRoy


Karl Seguin said:
Well, you can only read one at a time, which I assume is that the previous
poster was talking about...

But there's no built-in limitation. I imagine if you tried to receive a
billion rows something would go wrong. The real limitation is going to be
what you are storing the data into. I mean, if you discard the data via
something like:

while (dr.Read())
{
}

I imagine you could fetch an unlimited number of rows...


but if you are loading the data into something, like:

while(dr.Read())
{
users.Add(new User.CreateNewUser(dr));
}

you'll obviously eventually run out of memory because your user collection
is going to grow to be too much.

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top