Bind datareader to datagrid

R

Ricardo Luceac

Hi...

My program make a select to an table and return the results to a
datagrid, it's all ok with dataset, but in large tables it needs to get
the entire table to show in datagrid and sometimes it takes much time...

So I thik of use the datareader, but how can I bind the data that it is
picking from the database to the datagrid???

thx...
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Using the same way:

SqlDataReader reader = GetReader();
datagrid.DataSource = reader;
datagrid.DataBind();
reader.Close();

Note that you NEED to close the datareader !!! , otherwise you could let the
connection open.

Have you considered pagination?


cheers,
 
I

Ignacio Machin \( .NET/ C# MVP \)

Ricardo Luceac said:
Sory but what is that GetReader()???

That is any method that you use to get a DataReader, you hvae to change it
to reflect the name you used.
What is Pagination...

Is how you display a large table, you show only X records and use some way
to go a Next and/or Prev

cheers,
 

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

Top