ADO to ADO.NET in C#

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

Guest

H

I'm trying to find out how to enumerate the column names in an OdbcDataReader
whereas in VB6 I would have gon
For i = 0 to rs.Fields.Coun
Debug.Print rs.Fields(i).Nam
Nex

What can I do with an OdbcDataReader to achieve the same effect
I trie
dr.GetSchemaTable().Columns.GetEnumerator()
and looping through the caption property of the DataColumn objects within that collection but it was wrong, i.e. it wasn't the columns of my SQL query, more like some system columns or something
Thanks
 
Hi
Hi

I'm trying to find out how to enumerate the column names in an OdbcDataReader,
whereas in VB6 I would have gone
For i = 0 to rs.Fields.Count
Debug.Print rs.Fields(i).Name
Next

What can I do with an OdbcDataReader to achieve the same effect?
I tried
dr.GetSchemaTable().Columns.GetEnumerator();
and looping through the caption property of the DataColumn objects within that collection but it was wrong, i.e. it wasn't the columns of my SQL query, more like some system columns or something.
Thanks

Look in .NET docs for "IDataReader.GetSchemaTable Method"

Then you'll find that GetSchemaTable return your table description
in rows, but not in columns.

Think over your access to data by OdbcDataReader. If your results set
is not so big then you can simply import it into table by
*OdbcDataAdapter.Fill* method.

Regards

Marcin
 
Oh god yes you're right. Thanks.
But I've discovered the Fields collection and FieldCount property, which are
properties of the datareader.

Cheers

Marcin GrzÄTbski said:
within that collection but it was wrong, i.e. it wasn't the columns of my
SQL query, more like some system columns or something.
 
Back
Top