Avatar of gamesmeister
Flag for United Kingdom of Great Britain and Northern Ireland asked on

OleDB Type Mappings in an OleDbDataAdapter

I'm using the FillSchema method of an OleDbDataAdapter to retrieve the schema of some tables in my DB2 database. Unfortunately, columns of type Date, Time, and Timestamp are all mapped to a System.DateTime type, which is too generic for my application - I need to display the actual type (i.e Date, Time or Timestamp).

Is it possible for me to intercept the OleDbType of the column before it's mapped? And even if I can do that, how could I then store the type correctly within a DataColumn?

Many thanks

Avatar of undefined
Last Comment

8/22/2022 - Mon


The System.DateTime type can represent all of the possible values of a DB2 Date, Time, or Timestamp.  It should meet all of your needs.  i.e. if you only want to represent the Date, then ignore the Time part of the DateTime value.

Perhaps if you explained what you want to do with the value after you fill a DataSet using FillSchema someone would be able to point you in the right direction.

If you just want to display the value, there are many methods of DateTime that allow you to display just the Date, Just the Time or the Timestamp or whatever you want.


Thanks for the response

I want to display the schema of a DB2 database to my user i.e for a selected table, the user can see details of the columns in that table, including name, length and type. Therefore, if a column in the database is of the the type Time, I want to display that on a window. At the moment, FillSchema is just giving me a System.DateTime, and I've no idea whether that's a Date, a Time, or a Timestamp.

To make thngs slightly more difficult, it's possible that the tables will be empty, which means I can't extrapolate the type from data within the column.


View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.

Awesome, thx KL.

I have used this before, to get a list of table names within the database, but information on its usage is pretty sparse. Thx for all the examples, they're a big help. If you have any links that might give me the various options available, that would be very helpful, but this will keep me definitely keep me going for now.

Thx again
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck

You're welcome.  

I don't have any links with more info.  But, once you understand how GetOleDbSchemaTable works
then it's just a matter of going through the .Net  help for the members of "OleDbSchemaGuid" and seeing what information you get with each one as well as what "Restrictions" are available.

Also, the fact that you can cast the  DATA_TYPE int32 values into an OleDbType enum is very useful.  I didn't find that written anywhere, it just seemed like a good idea so I tried it and sure enough they match. Somebody thinks like me! (God help us)

Good Luck.