ODBC and Database Access

I am writing a program where the user connects to a database via ODBC.  When the program starts the user selects the ODBC driver that he\she wishes to use.  Is there a way to find out which database the user has connected to ?  This would be very useful for the program.
johnclarkeAsked:
Who is Participating?
 
KirkGrayConnect With a Mentor Commented:
For a list of installed alias's Use GetAliasNames (or something similiar - Method of Session or Database Component).

To get a list of Just ODBC DSN's Use the ODBC32.dll DataSources function.....or have a poke around in the registry..... But I reconmend the first way..

0
 
evansjCommented:
What type of database are you connecting to? SQL or desktop?
0
 
johnclarkeAuthor Commented:
The program will be connecting to SQL databases.

0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
ronit051397Commented:
You mean the Alias Name in the BDE or the Database itself like Oracle, Informix etc.?
0
 
johnclarkeAuthor Commented:
I mean the Database Name (eg Oracle, Informix, etc).
0
 
ronit051397Commented:
What initial parameters you have, the Alias Name?
0
 
johnclarkeAuthor Commented:
At the moment I am using the BDE which means that I have to use an alias name.  However,  I might decide to use the ODBC access components that are made by ODBCExpress since direct access to ODBC must be quicker than access via the BDE.
I would be grateful for any advice offered regarding either of the above methods for accessing databases via ODBC.
0
 
ronit051397Commented:
You can use TDatabase.DriverName
0
 
evansjCommented:
If you are using the BDE then check the native drivers under the native section in the BDE Admin. This provides direct access that's faster than ODBC.
0
 
KirkGrayCommented:
In retospect my answer is off the mark.  I am unsure how to get the database you have connected to using ODBC.  But ODBC32.dll would probably have a function somewhere that would help.
0
 
evansjCommented:
Just create an ODBC data source and select then DSN inside the data aware control under database.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.