Showing posts with label objecti. Show all posts
Showing posts with label objecti. Show all posts

Saturday, February 25, 2012

ODBC Provider for DSN through connection object?

Is it possible to find out Name or description of the ODBC driver using connection object?
I am not setting up the provider in the code. Only thing I set as connection string is the name of DSN. This DSN could point to any database, I need to figure out which databse it is (As in SqlServer or Oracle)! Hopefully I can do this using a connection object.

Can someone please direct me to the property that is can use for this? An exaple would be helpful, any help is appreciated.

--Shilpa

I know through non-managed code you can access this information through SQLGetInfo calls. For example:

SQLGetInfo(..., SQL_DBMS_NAME, ...) --> returns name of driver used in connection string

SQLGetInfo(..., SQL_DRIVER_NAME, ...) --> returns name of driver's DLL

SQLGetInfo(..., SQL_DRIVER_VER, ...) --> returns version of driver

There are many other keywords you can use to determine at runtime many attributes about the driver and the server. There's a more complete listing on http://msdn2.microsoft.com/en-us/library/ms131672.aspx

As an alternatve, and if you have access, you could browse your registry since this is where your DSN information is stored. (HKEY_LOCAL_MACHINE\SOFTWARE\ODBC for system DSN's, HKEY_CURRENT_USER\Software\ODBC for user DSN's).

~Warren