Cannot convert <type1> to <type2>
-
- Posts: 33
- Joined: Tue 25 Nov 2014 17:26
Re: Cannot convert <type1> to <type2>
THE PROBLEM PERSISTS!
...Expecting: Currency actual: Memo
Returning back to version 7.2.7
PLEASE TRY THE SAME SAMPLES I SENT YOU!
...Expecting: Currency actual: Memo
Returning back to version 7.2.7
PLEASE TRY THE SAME SAMPLES I SENT YOU!
Re: Cannot convert <type1> to <type2>
Hello,
I am using UniDAC 7.3.9 on Delphi 10.2.3 (all hotfixes and patches applied).
I confirm that I have same problem in a FMX project targetting Android platform.
Since I do not use any data aware components like DBGrid or smilar or any live binding with VirtualQuery, I used a workaround of accessing field as type string and converting it back to Currency, Double, etc.
I am using UniDAC 7.3.9 on Delphi 10.2.3 (all hotfixes and patches applied).
I confirm that I have same problem in a FMX project targetting Android platform.
Since I do not use any data aware components like DBGrid or smilar or any live binding with VirtualQuery, I used a workaround of accessing field as type string and converting it back to Currency, Double, etc.
Re: Cannot convert <type1> to <type2>
We sent the links for downloading the night build with the required changes related to fixing the described error, to all users who contacted us using e-support form (https://www.devart.com/company/contactform.html). Perhaps for technical reasons, we could not receive your request. Please provide your license number and the IDE version that you are using via e-support again
-
- Posts: 33
- Joined: Tue 25 Nov 2014 17:26
Re: Cannot convert <type1> to <type2>
But the problem still persists.
When using "SELECT SUM(Field1) Field2 FROM TABLE1" in a VirtualQuery from a VirtualTable is resulting Field2 as a MemoField that can nlt be mapped to currency...
It was perfect in version 7.2.7 and you have not been able to fix it in 2 releases and 3 night builds...
I hope you really have it fixed before next release.
When using "SELECT SUM(Field1) Field2 FROM TABLE1" in a VirtualQuery from a VirtualTable is resulting Field2 as a MemoField that can nlt be mapped to currency...
It was perfect in version 7.2.7 and you have not been able to fix it in 2 releases and 3 night builds...
I hope you really have it fixed before next release.
Re: Cannot convert <type1> to <type2>
We tested the work of the night build sent to you using the following console application:
Please, check the behavior of this sample in your environment and let us know the results. In case of the correct behavior, change the sample code in order for the issue to occur
Code: Select all
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils, Data.DB, VirtualTable, VirtualQuery;
var
VirtualTable: TVirtualTable;
VirtualQuery: TVirtualQuery;
begin
VirtualTable := TVirtualTable.Create(nil);
try
VirtualTable.FieldDefs.Add('Field1', ftCurrency);
VirtualTable.FieldDefs.Add('Field2', ftFloat);
VirtualTable.Open;
VirtualTable.Append;
VirtualTable.FieldByName('Field1').AsCurrency := 1;
VirtualTable.FieldByName('Field2').AsFloat := 2;
VirtualTable.Post;
VirtualQuery := TVirtualQuery.Create(nil);
try
VirtualQuery.SourceDataSets.Add(VirtualTable, '', 'TABLE1');
VirtualQuery.SQL.Text := 'SELECT SUM(Field1) As Field1, Field2 FROM TABLE1';
VirtualQuery.Open;
Assert(VirtualQuery.FieldByName('Field2').DataType = ftFloat);
finally
VirtualQuery.Free;
end;
finally
VirtualTable.Free;
end;
end.
Please, check the behavior of this sample in your environment and let us know the results. In case of the correct behavior, change the sample code in order for the issue to occur
-
- Posts: 33
- Joined: Tue 25 Nov 2014 17:26
Re: Cannot convert <type1> to <type2>
Why did not you try this code? if it is included in my sample...
Assert(VirtualQuery.FieldByName('Field1').DataType = ftCurrency);
It fails too!
Returning back to version 7.2.7
Please!!!
Assert(VirtualQuery.FieldByName('Field1').DataType = ftCurrency);
It fails too!
Returning back to version 7.2.7
Please!!!
Re: Cannot convert <type1> to <type2>
In the provided sample, FIELD1 is the result of the SUM function. Therefore, to represent this field with the ftCurrency type, you should use DataTypeMapping.
We changed the sample according to your description and successfully executed it using UniDAC 7.2.7, as well as using the UniDAC_27_08_2018 night build sent to you:
In both cases, we got an absolutely identical result. Please check the operation of the modified sample in your environment and let us know the results.
We changed the sample according to your description and successfully executed it using UniDAC 7.2.7, as well as using the UniDAC_27_08_2018 night build sent to you:
Code: Select all
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Data.DB,
VirtualTable,
VirtualQuery;
var
VirtualTable: TVirtualTable;
VirtualQuery: TVirtualQuery;
begin
VirtualTable := TVirtualTable.Create(nil);
try
VirtualTable.FieldDefs.Add('Field1', ftCurrency);
VirtualTable.FieldDefs.Add('Field2', ftFloat);
VirtualTable.Open;
VirtualTable.Append;
VirtualTable.FieldByName('Field1').AsCurrency := 1;
VirtualTable.FieldByName('Field2').AsFloat := 2;
VirtualTable.Post;
VirtualQuery := TVirtualQuery.Create(nil);
try
VirtualQuery.SourceDataSets.Add(VirtualTable, '', 'TABLE1');
VirtualQuery.SQL.Text := 'SELECT SUM(Field1) As Field1, Field2 FROM TABLE1';
VirtualQuery.Open;
Assert(VirtualQuery.FieldByName('Field1').DataType = ftFloat);
Assert(VirtualQuery.FieldByName('Field2').DataType = ftFloat);
VirtualQuery.Close;
VirtualQuery.DataTypeMap.AddFieldNameRule('Field1', ftCurrency);
VirtualQuery.Open;
Assert(VirtualQuery.FieldByName('Field1').DataType = ftCurrency);
Assert(VirtualQuery.FieldByName('Field2').DataType = ftFloat);
finally
VirtualQuery.Free;
end;
finally
VirtualTable.Free;
end;
end.
Re: Cannot convert <type1> to <type2>
Hello,
I just tested Night build from 3rd of September.
I confirm that Win32 platform does not have any problem. However, problem still continues on FMX platform. You should also make some tests on FMX platform.
Thanks & regards,
Ertan
I just tested Night build from 3rd of September.
I confirm that Win32 platform does not have any problem. However, problem still continues on FMX platform. You should also make some tests on FMX platform.
Thanks & regards,
Ertan
Re: Cannot convert <type1> to <type2>
To investigate the issue, please compose and send us the simplest FMX application, execution of which causes the issue. It is convenient to do it using the e-support form ( https://www.devart.com/company/contactform.html )
Re: Cannot convert <type1> to <type2>
I reproduced my case of problem on all platforms.
When field value tried to be reached as float/currency and it has Null value, exception raises. Maybe, there should be a parameter to return a zero (0) in such a case, or it maybe a default behavior.
When field value tried to be reached as float/currency and it has Null value, exception raises. Maybe, there should be a parameter to return a zero (0) in such a case, or it maybe a default behavior.
Code: Select all
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Data.DB,
VirtualTable,
VirtualQuery;
var
VirtualTable: TVirtualTable;
VirtualQuery: TVirtualQuery;
ValueCurr: Currency;
begin
VirtualTable := TVirtualTable.Create(nil);
try
VirtualTable.FieldDefs.Add('Field1', ftCurrency);
VirtualTable.FieldDefs.Add('Field2', ftFloat);
VirtualTable.Open;
// VirtualTable.Append;
// VirtualTable.FieldByName('Field1').AsCurrency := 1;
// VirtualTable.FieldByName('Field2').AsFloat := 2;
// VirtualTable.Post;
VirtualQuery := TVirtualQuery.Create(nil);
try
VirtualQuery.SourceDataSets.Add(VirtualTable, '', 'TABLE1');
VirtualQuery.SQL.Text := 'SELECT SUM(Field1) As Field1, Field2 FROM TABLE1';
VirtualQuery.Open;
Assert(VirtualQuery.FieldByName('Field1').DataType = ftFloat);
Assert(VirtualQuery.FieldByName('Field2').DataType = ftFloat);
VirtualQuery.Close;
VirtualQuery.DataTypeMap.AddFieldNameRule('Field1', ftCurrency);
VirtualQuery.Open;
ValueCurr := VirtualQuery.FieldByName('Field1').AsCurrency; // Here you will get exception
finally
VirtualQuery.Free;
end;
finally
VirtualTable.Free;
end;
end.
Re: Cannot convert <type1> to <type2>
Thank you for the information. We will investigate the described issue and let you know the results shortly.
-
- Posts: 33
- Joined: Tue 25 Nov 2014 17:26
Re: Cannot convert <type1> to <type2>
That is as I have in my samples, but they ran with data and my samples were empty/null records/fields
Thank you for explaining better, I was just keeping saying that the problem persisted and it did, but did not say a thing that helped.
Thank you again, I hope they now have it fixed!
Thank you for explaining better, I was just keeping saying that the problem persisted and it did, but did not say a thing that helped.
Thank you again, I hope they now have it fixed!
-
- Posts: 33
- Joined: Tue 25 Nov 2014 17:26
Re: Cannot convert <type1> to <type2>
That is as I have in my samples, but they ran with data and my samples were empty/null records/fields
Thank you for explaining better, I was just keeping saying that the problem persisted and it did, but did not say a thing that helped.
Thank you again, I hope they now have it fixed!
ALL MY TESTS ARE IN FMX (Android) NOT VCL PROJECTS!
Thank you for explaining better, I was just keeping saying that the problem persisted and it did, but did not say a thing that helped.
Thank you again, I hope they now have it fixed!
ALL MY TESTS ARE IN FMX (Android) NOT VCL PROJECTS!
Re: Cannot convert <type1> to <type2>
Thank you for the information. We reproduced the issue and fixed this error. The links to download the night build with the required changes were sent to your email.
-
- Posts: 33
- Joined: Tue 25 Nov 2014 17:26
Re: Cannot convert <type1> to <type2>
It is almost unbelievable!
No error messages, but no fine working neither!
VirtualTable empty in design time...All SUM(Fieldx) in VirtualQuery result in null
VirtualTable with a record in design time... Everything works fine!
VirtualTable with a record in design time, records added... Everything works fine!
VirtualTable with a record in design time, table cleared then records added... All SUM fields are null
Everything was fine in version 7.2.7
Trying to deal with it before returning to version 7.2.7
No error messages, but no fine working neither!
VirtualTable empty in design time...All SUM(Fieldx) in VirtualQuery result in null
VirtualTable with a record in design time... Everything works fine!
VirtualTable with a record in design time, records added... Everything works fine!
VirtualTable with a record in design time, table cleared then records added... All SUM fields are null
Everything was fine in version 7.2.7
Trying to deal with it before returning to version 7.2.7