开发者

Retrieving datatypes from underlying database

开发者 https://www.devze.com 2022-12-30 18:26 出处:网络
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 dat开发者_Stac

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 dat开发者_StackOverflowatype 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?


It seems that there is no uniform way of doing this. I extract my datatypes from the schema query on OleDb and convert the datatype to the representation i need, and does the same for the Odbc connection. This layer of "translation" between the datatypes seems to be the only way.

0

精彩评论

暂无评论...
验证码 换一张
取 消