sniles
asked on
Detecting underlying database type under ODBC
Because of a difference in the way dates are presented for comparison in WHERE expressions (see http://www1.experts-exchange.com/questions/10320535/comparing-a-datetime-in-WHERE-clause-inMFC-CRecordset.html) , I need to know what type of database is being used for my MFC ODBC app. I tried using CDatabase::GetConnect() to get the connect string and found FIL=MS Access; when ODBC data source used Access, but no such string was returned under MS SQL Server 7.0.
How can I detect the underlying database type?
How can I detect the underlying database type?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
While this question was open, I found another way to find the info (although I prefer your solution, which makes this info unnecessary):
#include <SQL.H>
char dbms_info[256];
SQLSMALLINT dbms_info_len;
int rc = SQLGetInfo( m_database.m_hdbc,
SQL_DBMS_NAME,
(SQLPOINTER) dbms_info, (SQLSMALLINT) sizeof(dbms_info),
(SQLSMALLINT *) &dbms_info_len);
When this call returns, dbms_info contains "ACCESS" or "Microsoft SQL Server" (haven't tested other values).
While this question was open, I found another way to find the info (although I prefer your solution, which makes this info unnecessary):
#include <SQL.H>
char dbms_info[256];
SQLSMALLINT dbms_info_len;
int rc = SQLGetInfo( m_database.m_hdbc,
SQL_DBMS_NAME,
(SQLPOINTER) dbms_info, (SQLSMALLINT) sizeof(dbms_info),
(SQLSMALLINT *) &dbms_info_len);
When this call returns, dbms_info contains "ACCESS" or "Microsoft SQL Server" (haven't tested other values).
[My Computer\HKEY_CURRENT_USER
There should be keys here for each DSN, look for the key with the same name as the DSN you app is using, the data value for the key is the ODBC driver name.