Click to See Complete Forum and Search --> : How to figure if it's Oracle, MSSQL or Access i'm connected to right now via ODBC/ADO


inner
December 5th, 2003, 09:53 AM
:confused:
Seems like a basic question.
I need to know at run time what database type I'm connected to. Oracle, MSSQL or Access. Via ODBC and/or ADO.
Need it badly!
Thanks a lot guys.

M Owen
December 5th, 2003, 01:09 PM
You should be able to determine that by the provider info in your connection string.

inner
December 5th, 2003, 01:18 PM
Originally posted by M Owen
You should be able to determine that by the provider info in your connection string.
At least in ADO connection string reports only MSDASQL.
I'm checking ODBC...

Thread1
December 5th, 2003, 10:00 PM
How about the Driver parameter?

M Owen
December 8th, 2003, 07:01 AM
The only time that you will get the MSDASQL provider is when you use a DSN ... What I was talking about was the explicit provider info specified by "PROVIDER= ..." setting.

inner
December 8th, 2003, 03:35 PM
Originally posted by M Owen
The only time that you will get the MSDASQL provider is when you use a DSN ... What I was talking about was the explicit provider info specified by "PROVIDER= ..." setting.
You mean "provider" prop? Still "MSDASQL.1"

kimmckenzie
December 8th, 2003, 04:45 PM
Make it part of the setup info and request it from the user during installation then store it in an ini or the registry. You either have to build the database or have them point you to one anyway don't you?

:D

inner
December 8th, 2003, 04:51 PM
Originally posted by kimmckenzie
Make it part of the setup info and request it from the user during installation then store it in an ini or the registry. You either have to build the database or have them point you to one anyway don't you?

:D

Wow! That's a loooooooooong way aroung! :D

kimmckenzie
December 8th, 2003, 05:02 PM
Ok, you have to a have valid connection string to get to a database right? If you don't have a valid connection string then how are you going to get to the database to ask what kind it is? And you should only have to build your connection string one time in the application. Get the database type when you get the database name, the user, name and the password.

Not such a long way around.

inner
December 8th, 2003, 05:08 PM
See! Here is where you assume wrong :

...only have to build your connection string one time in the application...

I work with possible multiple different DSNs and they could be changed by user in run-time. So I need to know this dynamically.

kimmckenzie
December 8th, 2003, 05:21 PM
You only have to build it one time for each database.


Anyway try using the file name property.


If that doens't work then try something that is database specific for each type of database that you are supplying code for. Say selecting from a system table that only exists in the specific type of database.

Thread1
December 8th, 2003, 09:19 PM
Ok:D.. Checkout the following properties of the connection object, even the "Entended Properties" could provide you the info..


MsgBox m_cn.Properties("DBMS Name").Value
MsgBox m_cn.Properties("Server Name").Value

inner
December 9th, 2003, 12:04 PM
Originally posted by Thread1
Ok:D.. Checkout the following properties of the connection object, even the "Entended Properties" could provide you the info..


MsgBox m_cn.Properties("DBMS Name").Value
MsgBox m_cn.Properties("Server Name").Value


:eek:

Wow! Now! That IS perfect! Coooool!
High five!

:D

Thanks a lot!