Is there anyway to get list of data sources names registered with ODBC Administrator (User DSN or System DSN).
I tried with UniConnection.GetDatabaseNames(List), but I only receive error [Microsoft][ODBC Ohjaintenhallinta] Datasource name not found and default driver is not defined. (Sorry might not be correct error, this is translated from Finnish)
Get ODBC Datasourcenames?
Re: Get ODBC Datasourcenames?
Hello,
You can retrieve the list of registered DSN using the UniConnectDialog.GetServerList method:
You can retrieve the list of registered DSN using the UniConnectDialog.GetServerList method:
Code: Select all
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils, Classes, Uni, ODBCUniProvider, UniDacVcl;
var
UniConnection: TUniConnection;
UniConnectDialog: TUniConnectDialog;
Lst: TStringList;
i: integer;
begin
UniConnection := TUniConnection.Create(nil);
try
UniConnection.ProviderName := 'ODBC';
UniConnectDialog := TUniConnectDialog.Create(nil);
try
UniConnection.ConnectDialog := UniConnectDialog;
UniConnectDialog.UseServerHistory := False;
Lst := TStringList.Create;
try
UniConnectDialog.GetServerList(Lst);
for i := 0 to Lst.Count - 1 do
Writeln(Lst[i]);
finally
Lst.Free;
end;
finally
UniConnectDialog.Free;
end;
finally
UniConnection.Free;
readln;
end;
end.