What happend to SpecifiOptions?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
invent
Posts: 92
Joined: Tue 16 Jun 2009 10:59
Location: Bielefeld, Germany

What happend to SpecifiOptions?

Post by invent » Thu 19 Jan 2017 13:40

Hello,

I just made an Update form UniDac 4.5.9 to 6.4.16 and my programm doesn't work anymore.

The Problem ist in TUniConnection.SpecificOptions.

In UniDac 4.5.9 I use the SpecificOptions parameter to define some own options. Example:

MyUniConnection.SpecificOptions.Add ('MyOptions.Logfile=C:\Temp\DBLog.txt');

That works fine in UniDac 4.5.9. In Version 6.4.16 occurs an error:

"MyOptions is not a valid provider name".

Why is this changed? And what can I do to make my own options for a TUniConnection?

Kind Regards,
Gerd Brinkmann
invent GmbH

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: What happend to SpecifiOptions?

Post by AlexP » Thu 19 Jan 2017 14:07

Hello,

In the new version we have introduced a check for SpecificOptions and their values. Now, when you try to use a non-existent option, or assign an invalid value, you will receive an error message.
You can add your options the same way as the standard ones in the XXXUniProvider.pas file in the CreateConnectionOptions method

invent
Posts: 92
Joined: Tue 16 Jun 2009 10:59
Location: Bielefeld, Germany

Re: What happend to SpecifiOptions?

Post by invent » Thu 19 Jan 2017 14:38

Hello,

thanks for the quick response. Sorry, but I fail to see what you mean.

I just have a TUniConnection and there is no CreateConnectionOptions method.

I think I use the macros to add my own options. Does this work, when I never use the macro-name in my queries?

Thanks in advance,
Gerd Brinkmann
invent GmbH

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: What happend to SpecifiOptions?

Post by AlexP » Mon 23 Jan 2017 08:21

Please describe in more details the behavior you want to implement in macros - and we will try to help you resolve the issue.

invent
Posts: 92
Joined: Tue 16 Jun 2009 10:59
Location: Bielefeld, Germany

Re: What happend to SpecificOptions?

Post by invent » Mon 23 Jan 2017 14:06

Hello,

i have some own parameters in a TUniConnection, because I need them later in the project. For example I want to log query-errors in a local file:

Code: Select all

try
  UniQuery1.Execute;
except
  on E : Exception do
    WriteQueryErrorToLogfile (E.Message, UniQuery1.Sql);
end;
In UniDac 4.5.9 I used for this TUniConnection.SpecificOptions. On program-start I set the options:

Code: Select all

UniConnection1.SpecificOptions.Clear;
UniConnection1.SpecificOptions.Add ('MyOptions.LogFilename=C:\MyLogFile.txt');
UniConnection1.Connect;
Later in project or in a dll:

Code: Select all

procedure WriteQueryErrorToLogfile (...);
begin
for i := 0 to UniQuery1.Connection.SpecificOptions.Count - 1 do
  begin
  if Pos ('MyOptions.LogFilename=', UniQuery1.Connection.SpecificOptions [i]) > 0
    then begin
         SpezOption := UniQuery1.Connection.SpecificOptions [i];
         LogFilename := copy (SpezOption, ...);
         end;
  end;
(...);
end;
In UniDac 6.4.16 I cannot use the SpecificOptions like in 4.5.9. So I make some makros for this:

Code: Select all

UniConnection1.Macros.Clear;
UniConnection1.Macros.Add ('MyOptions.LogFilename', 'C:\MyLogFile.txt', '');
UniConnection1.Connect;
Later in project or in a dll:

Code: Select all

procedure WriteQueryErrorToLogfile (...);
begin
for i := 0 to UniQuery1.Connection.Macros.Count - 1 do
  begin
  if UniQuery1.Connection.Macros.Items [i].Name = 'MyOptions.LogFilename'
    then LogFilename := UniQuery1.Connection.Macros.Items [i].Value;
  end;
(...);
end;
It's clear, that the macro is not really used in sql. Are there any reasons against this solution?

King regards,
Gerd Brinkmann
invent GmbH

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: What happend to SpecifiOptions?

Post by AlexP » Tue 24 Jan 2017 08:27

Macros are designed for other purposes, but you can use them in your case. In addition there are many other ways to set parameters, such as global variables, inheritance from our TuniConnection and adding your field, creating a separate class for error handling and so on.

invent
Posts: 92
Joined: Tue 16 Jun 2009 10:59
Location: Bielefeld, Germany

Re: What happend to SpecifiOptions?

Post by invent » Tue 24 Jan 2017 12:35

Hello AlexP,

thanks for your answer and you're right.

In my biggest project I have 1 x TUniConnection and circa 2.000 x TUniQuery. So I made a new class from TUniQuery for error handling. But I was too lazy to make a new class for 1 TUniConnection.

Kind regards,
Gerd Brinkmann
invent GmbH

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: What happend to SpecifiOptions?

Post by AlexP » Wed 25 Jan 2017 08:25

If you have any other questions, feel free to contact us

Post Reply