What happend to SpecifiOptions?
What happend to SpecifiOptions?
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
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
Re: What happend to SpecifiOptions?
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
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
Re: What happend to SpecifiOptions?
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
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
Re: What happend to SpecifiOptions?
Please describe in more details the behavior you want to implement in macros - and we will try to help you resolve the issue.
Re: What happend to SpecificOptions?
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:
In UniDac 4.5.9 I used for this TUniConnection.SpecificOptions. On program-start I set the options:
Later in project or in a dll:
In UniDac 6.4.16 I cannot use the SpecificOptions like in 4.5.9. So I make some makros for this:
Later in project or in a dll:
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
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;
Code: Select all
UniConnection1.SpecificOptions.Clear;
UniConnection1.SpecificOptions.Add ('MyOptions.LogFilename=C:\MyLogFile.txt');
UniConnection1.Connect;
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;
Code: Select all
UniConnection1.Macros.Clear;
UniConnection1.Macros.Add ('MyOptions.LogFilename', 'C:\MyLogFile.txt', '');
UniConnection1.Connect;
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;
King regards,
Gerd Brinkmann
invent GmbH
Re: What happend to SpecifiOptions?
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.
Re: What happend to SpecifiOptions?
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
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
Re: What happend to SpecifiOptions?
If you have any other questions, feel free to contact us