简体   繁体   中英

Need to get the Installed ODBC Driver details

mySql and Oracle drivers in odbc to connect my application.By Now i need to get the connected driver details. (Ie) if am connecting a sql datatbase in odbc,how to find that its an SQL similarly for mySql and Oracle. By using this i can only get the DSN Name,Not the driver type or driver details

 reg = reg.OpenSubKey("ODBC");
        if (reg != null)
        {
            reg = reg.OpenSubKey("ODBC.INI");
            if (reg != null)
            {
                reg = reg.OpenSubKey("ODBC Data Sources");
                if (reg != null)
                {
                    // Get all DSN entries defined in DSN_LOC_IN_REGISTRY.
                        foreach (string sName in reg.GetValueNames())
                        {Messagebox.Show(sName);
                        }
                }
            }
        }

NOTE :I can get the dll name in opened connection by its connection extension DRIVER but it is giving the driver's dll name only.But i need to identify the driver type wether the connection is a SQL or MySQL od ORACLE ..??

I don't think that is possible. Have a look for example at drivers for Microsoft Access/dBase/Excel. They all use the same DLL, in my case C:\\PROGRA~2\\COMMON~1\\MICROS~1\\OFFICE14\\ACEODBC.DLL

So, you cannot say a DLL connects to one single database server only.

If you have established a connection to a database using one of the DSN entries (or a connection-string) you can use the SQLGetInfo() Function to query various details about the driver or database, like SQL_DRIVER_NAME, etc.

But I dont know if this really helps you, as this needs an established connection to the database..

see: https://msdn.microsoft.com/en-us/library/ms711681%28v=vs.85%29.aspx

You can use SQLGetInfo() with the argument SQL_DBMS_NAME to get the name of the Database Product. This will fill the buffer pointed to by InfoValuePtr with values like Microsoft SQL Server for SQLServer or MySQL for MySQL, etc. The exact value depends on the driver.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM