Retrieving column datatypes

  • Thread starter Thread starter Paul K
  • Start date Start date
P

Paul K

I am currently trying to find a way to retrieve column
datatypes for use in a managed component. I have looked
at using the OleDbConnection.GetOleDbSchemaTable method
and the OleDbDataReader.GetSchemaTable method.

The OleDbDataReader.GetSchemaTable method provides the
information I need, but I don't want the connection open
any longer than it has to be. The OleDbSchemaGuid used in
OleDbConnection.GetOleDbSchemaTable doesn't seem to
provide a field for retrieving metadata on any column (not
just the pk or fks).

Does anyone know if there are any other ways to retrieve
any columns metadata (especially datatype)?

Thanks!

Paul K
 
DataAdapter.FillSchema?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
William,

I looked at FillSchema and tried it, but the only thing
it returned was the query data, but no metadata on
columns (tried passing a DataSet containing one DataTable
as well as passing a single DataTable - both yielded the
same result)???

Even if I take the time to get it to work properly, it
looks like I would still need to keep the connection open
as there are multiple tables that I would need to query.

Hmmm... I COULD just join all fourteen tables together in
an ad hoc query; that way I only have to deal with one
DataTable :)

But seriously, I'm looking for a format something like
what the OleDbConnection.GetOleDbSchema returns -- a
listing of all tables and columns as well as metadata
about each. I'd rather not require the client
application to provide a connection to the component I'm
designing unless I have to, since I'm planning on using
it in other applications and may possibly distribute it
to other developers.

Thanks for your help!

Paul K
-----Original Message-----
DataAdapter.FillSchema?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and
confers no rights.
 
Hi Paul,

I think I do it in the way you describe, but also on an easy way, you can
take a look for this, because this was the thing to overcome when I did
that, the dataset had no things like a primary key and so. (You can make of
course for every dataset an XML scheme, but I did find that a lot of work
for simple things)

Dim dsKey(0) As DataColumn
or
Datacolumn dsKey;

dsKey(0) = dataset1Per.Tables(0).Columns("ident")
dataset1.Tables(0).PrimaryKey = dsKey
dsKey(0) = dataset.Tables(0).Columns("ident")

I hope this brings you on the route.

Cor
 
Back
Top