I have an application that connects via a DSN to an Oracle database. If the initial attempt to connect fails, then I make sure their DSN exists. If it does not exist, then I create it using the SQLConfigDataSource command.
That command requires the driver name as one of its arguments. On my machine, I have the 11g driver, so the following works:
const
cDriver = 'Oracle in OraDb11g_home1' + #0;
var
strAttr: string;
begin
strAttr := 'DSN=' + DSNName + #0 +
'SERVER=' + TNSName + #0;
SQLConfigDataSource(0,ODBC_ADD_SYS_DSN,PChar(cDriver),PChar(strAttr));
end;
But the client machine might have a different version of Oracle, or a different name for their oracle home. How can I tell which driver to use on an arbitrary machine?
I'm using Delphi, but it shouldn't matter much, since this is just an API call anyway.