How can I display the result of a DataReader in a DataGridView?

J

Jorge EA

Hi there,

I am using VC# Express (beta 1) and as the subject says, here's what I am
trying to do:

FbConnection conn = new FbConnection(conn_str);
FbCommand cmd = new FbCommand("select numero,nombre,ciudad from
clientes", conn);

conn.Open();

FbDataReader myReader;
myReader=cmd.ExecuteReader();

dgvResultados.DataSource = myReader;
myReader.Close();

myReader has data, I can see it with a MessageBox.Show(), however, the
DataGridView shows nothing at all. Using the ASP grid, this works. Am I
missing something to make it work in WindowsForms as well?

Thanks in advance,

-Jorge

I
 
J

jalpizar

Hello Jorge,

DataReader is a forward only stream, yo should use a DataApdater and
a DataSet for you to be able to display the data in the DataGridView
Saludos,
Javier.
 

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