Retrieving datatypes from underlying database

Posted by H4mm3rHead on Stack Overflow See other posts from Stack Overflow or by H4mm3rHead
Published on 2010-05-17T06:01:44Z Indexed on 2010/05/18 7:10 UTC
Read the original article Hit count: 273

Filed under:
|
|

Hi, Im making an application that displays information about an underlying database. The database can be anything, but is typically either Oracle, MSSQL or MySQL. I am trying to extract the datatype but cannot seem to get this right. I have a DbConnection because i dont know whether I need a OleDbConnection or an OdbcConnection. On this connection I make a GetSchema("Columns", "mytablename") query and gets the result back. It seems though that there are some inconsistencies with my datatypes or the query returns different datatypes for the different databases.

For instance, in my MSSQL database I query and get an integer back (which seems to be the OleDbType) which I map to a datatype. My varchars is now of type char - no length - and this confuses me a bit.

I guess my main question is something like: Is there any way of making a uniform way of extracting datatypes across providers and having an "accurate" representation of the datatype?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about datatype