AlexP wrote:
The provider name is set as a string value, since it can also be specified in the ConnectString property.
Yes, I know that. At startup of the application the provider is set, but later, in a different part of the code I want to do something depending on the provider chosen earlier.
For example:
Code: Select all
if UniConnection.ProviderName = 'PostgreSQL' then
begin
// This code will get executed.
end;
if UniConnection.ProviderName = 'Postgres' then
begin
// This code will NEVER get executed, but you will only
// discover this when stepping through the code with the debugger.
end;
Compare this to:
Code: Select all
if UniConnection.ProviderType = UNIDAC_POSTGRESQL then
begin
// This code will get executed.
end;
if UniConnection.ProviderType = UNIDAC_POSTGRES then
begin
// This code will not compile if the particular constant hasn't been defined.
// You will notice your error right away.
end;
The use of constants is preferred above string compares.