Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Issues with GetData


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Jan 23, 2018 9:45 AM Last Post By: Mark Williams
Mark Williams

Posts: 120
Registered: 5/8/10
Issues with GetData  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 6:33 AM
Using Rad Studio 10.2

Issues with GetData

I am getting an inconsistent access violation working with the GetData function with table rows. Sometimes I run my app and getData works every time. Other times I run it and it fails every time. It doesn't seem to matter whether there is a recompile or not.

The code is as follows
btnID.Caption := 'ID: '+varToStr(FDQuery.sourceView.rows[Index].GetData(documents_id));
lPath.Caption:=getDocumentFullPath(FDQuery, index);

Setting the caption of btnID always works. Setting lPath.caption works sometimes and not others.

The function GetDocumentFullPath is declared

Function getDocumentFullPath(FDQuery:TFDQuery; index:integer):string;
begin
Result:=getDocumentFullPath(FDQuery.SourceView.Rows[Index]);
end;

It passes a TFDDatsRow paramater to an overloaded function declared (relevant extract only)

Function getDocumentFullPath(Row:TFDDatSRow):string;
var
fp : variant;
begin
with Row do
begin
if GetData(documents_tab_type)<>0 then
exit;

fp:=GetData(documents_file_path); {crashes here}
end;

In the overloaded function it handles the documents_tab_type field with no problem, but not the assigning of the documents_file_path to the variant fp.

Can anyone advise why this is intermittently causing me problems?

I am working with MySQl. "documents_file_path" is a varchar with a length of 300.

Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Issues with GetData  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 7:33 AM   in response to: Mark Williams in response to: Mark Williams
Can you provide the call stack for Access Violation ?
Can you provide a reproducible test case ?

--
With best regards,
Dmitry
Mark Williams

Posts: 120
Registered: 5/8/10
Re: Issues with GetData  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 8:30 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Can you provide the call stack for Access Violation ?

After it calls my function GetDocumentFullPath, it passes to FireDAC.DatS getData lines 9958 and then to 10133 where it falls over with an EAccessViolation.

Don't have the source so can't say precisely what is causing the problem. I am using 10.2 Update 1,

Can you provide a reproducible test case ?

Probably not. It's an intermittent bug.

Any ideas as to what may be causing it and what I could do to avoid it?

I can run my app and it works okay. I can shut it down and re-open it and 5 times in a row all will be fine, and then I can close and re-open it two or three times and it will crash on each occasion. Even without changing the code or even re-compiling.
Mark Williams

Posts: 120
Registered: 5/8/10
Re: Issues with GetData  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 23, 2018 3:56 AM   in response to: Mark Williams in response to: Mark Williams
I have found the answer. It was an error with a constant value used as a place holder. Dmitry, apologies for wasting your time.
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Issues with GetData  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 23, 2018 9:28 AM   in response to: Mark Williams in response to: Mark Williams
So, it was not an EAccessViolation, but some other exception ?

--
With best regards,
Dmitry
Mark Williams

Posts: 120
Registered: 5/8/10
Re: Issues with GetData  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 23, 2018 9:45 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
So, it was not an EAccessViolation, but some other exception ?

No, it was an EAccessViolation that was being reported.

Because of an error over a constant place holder I was trying to access a column in the row that did not exist. It's odd because 50% of the time, no error was reported, but the column still did not exist!
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02