Filling a data grid with a Datareader

G

Guest

Hi, I'm using a SP with one input parameter to return query results to a
Datareader. I then want to add the rows in the data reader into a data grid.

Can you 'bind' a datareader to a data grid? If not, how would do it?

The data grid will be read only.

What is the best approach for this? Datareader? Data set? If so, how would I
return the resultant rows from the SP into a data set. I'm quite new to
ADO.NET

Many thanks in advance for any ideas
Ant
 
C

Cor Ligthert [MVP]

Ant,

This newsgroup is full of people who tell that they use a stored procedure.
For AdoNet that is not so interesting (you have to use parameters, however
that you should forever).

More interesting for this question is if you use a windowforms datagrid or a
webform datagrid.

To the last you can bind the datareader to that datagrid using its
datasource and after that databind that. For the first you cannot.

I hope this helps,

Cor
 
G

Guest

Hi Cor,

I'm using a Web form datagrid so i guess I can't bind it. So then, how would
I load the Datareader data into the datagrid? What methods does the Datagrid
expose to allow me to do this?

Thanks
 

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