G
Guest
I am moving a project over from VS2003 to VS2005. It is an adhoc data mining
tool that lets you explore tabular data from just about any source.
In it I use SqlConnection, OracleConnection, OledbConnection, and
OdbcConnection as needed. For each type I had special code to get the tables
and a table's columns where the columns data types are very important to me.
For Sql and Oracle I executed queries, for Oledb I used the
GetOleDbSchemaTable(), and for Odbc I used calls to an ADODB (old ado)
Interop assembly to the GetSchema() call of OleDb using the MSDASQL provider
to pass through to ODBC. They all work but are a lot of work to maintain.
I was looking forward to getting rid of all the specialized code and the
interop assembly by using the new GetSchema() function. But I have found
that even though it exists for each connection, it doesn't return results
that are consistent across connection types, and worse it isn't even
consistent within Odbc for sure, maybe Oledb too.
Calling GetSchema( "Columns" ) results in a table with the DATA_TYPE column
containing text for Sql and integers of Odbc. The Sql ones are obvious and
easy to deal with, but the Odbc ones are NOT values that come even close to
the OdbcType enumeration's values.
For instance, connecting to MS-Access using ODBC, DATA_TYPE contains -9 for
a Text column, but OdbcType.Text == 18.
And on top of that, using OdbcConnection to connect to dBase or Paradox
using the Jet driver, a call to GetSchema( "Columns" ) returns an EMPTY
dataset!
So, does anyone know:
1) Am I crazy to expect a common function to return common results?
2) How to interpret the DATA_TYPE column from GetSchema( "Columns" ) for Odbc.
3) Why do I get no results from GetSchema( "Columns" ) for some
drivers/providers when a connection will return a valid data reader?
4) Is there a better way to get the column names and types for any given
connection in a consistent way?
tool that lets you explore tabular data from just about any source.
In it I use SqlConnection, OracleConnection, OledbConnection, and
OdbcConnection as needed. For each type I had special code to get the tables
and a table's columns where the columns data types are very important to me.
For Sql and Oracle I executed queries, for Oledb I used the
GetOleDbSchemaTable(), and for Odbc I used calls to an ADODB (old ado)
Interop assembly to the GetSchema() call of OleDb using the MSDASQL provider
to pass through to ODBC. They all work but are a lot of work to maintain.
I was looking forward to getting rid of all the specialized code and the
interop assembly by using the new GetSchema() function. But I have found
that even though it exists for each connection, it doesn't return results
that are consistent across connection types, and worse it isn't even
consistent within Odbc for sure, maybe Oledb too.
Calling GetSchema( "Columns" ) results in a table with the DATA_TYPE column
containing text for Sql and integers of Odbc. The Sql ones are obvious and
easy to deal with, but the Odbc ones are NOT values that come even close to
the OdbcType enumeration's values.
For instance, connecting to MS-Access using ODBC, DATA_TYPE contains -9 for
a Text column, but OdbcType.Text == 18.
And on top of that, using OdbcConnection to connect to dBase or Paradox
using the Jet driver, a call to GetSchema( "Columns" ) returns an EMPTY
dataset!
So, does anyone know:
1) Am I crazy to expect a common function to return common results?
2) How to interpret the DATA_TYPE column from GetSchema( "Columns" ) for Odbc.
3) Why do I get no results from GetSchema( "Columns" ) for some
drivers/providers when a connection will return a valid data reader?
4) Is there a better way to get the column names and types for any given
connection in a consistent way?