Solved

Detecting underlying database type under ODBC

Posted on 2000-04-04
3
732 Views
Last Modified: 2008-02-20
Because of a difference in the way dates are presented for comparison in WHERE expressions (see http://www1.experts-exchange.com/Computers/Databases/SQL/Q_10320535.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?
0
Comment
Question by:sniles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Accepted Solution

by:
twol earned 200 total points
ID: 2687101
Simply by adding a few functions to make generic odbc calls, you should have no problems between these two environments ( I've already done this).

Use the info at this page to see how to make generice odbc SQL statements.

http://support.microsoft.com/support/kb/articles/Q142/9/30.asp
0
 
LVL 4

Expert Comment

by:kpkp
ID: 2687127
If you can get you app to read registry entries at run time, look for a key in
[My Computer\HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\]

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.
0
 

Author Comment

by:sniles
ID: 2688354
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).
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question