Delphi 7 :: TADOQuery OnAfterScroll Error with parameters

Dear Experts,

I have 2 TDBGrid components.
The 1st one must display master table records and the second one displays detail table records
for the selected row in the master table.
qOrders = Master Query
qParts = Detail Query.

On qOrders' OnAfterScroll event I have the following code:
**** PS: See code snippet.

When my application starts up I receives and error:
"EDatabaseError with message 'qParts: Parameter 'POrderNumber' not found'...."
This parameter does exist and when I click the error message away the application starts up and
when scrolling through the master dbgrid the code is working 100%. It is only when the app starts up when I receive this error. After that, it is working as expected.

What can possible be wrong?

Please help.
procedure TPickingListFrame.qOrdersAfterScroll(DataSet: TDataSet);
begin
  inherited;
  If qOrders.IsEmpty then Exit;
 
  qParts.Close;
  qParts.SQL.Clear;
  qParts.SQL.Text := 'SELECT POrderNumber, ItemNumber, ItemDescription, Qty FROM tblCallOff WHERE '+
    '(POrderNumber = :POrderNumber) AND (Deleted = :Deleted) ORDER BY ItemNumber';
  qParts.Parameters.ParamByName('POrderNumber').Value := qOrders.FieldByName('POrderNumber').AsString;
  qParts.Parameters.ParamByName('Deleted').Value := 0;
  qParts.Open;
end;

Open in new window

Marius0188Asked:
Who is Participating?
 
developmentguruConnect With a Mentor PresidentCommented:
With my own testing I verified your results.  I also discovered that having an active TADOConnection (referenced by the ADOQuery) corrected the situation.

Let me know if you need more.
0
 
kretzschmarCommented:
ensure, that the ParamCheck-property of the TAdoQuery is set to true

meikl ;-)
0
 
kretzschmarCommented:
in case that the sql don't change during runtime (except the parameterValues),
you could simple close, set the parameter and open again
(a clear and new set of the sql is not needed then)
(would be also raise the performance)

meikl ;-)
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
JeePeeTeeCommented:
Is your DBConnection and your qOrders/qPart opened at designtime? Close them before you launch you application.
0
 
diniludCommented:
are you sure the error from "qOrdersAfterScroll" event
0
 
diniludCommented:
Change component creation order of these two components.
(qOrders,qParts)
0
 
diniludCommented:
Set Active property of qOrders equal to false. then open this dataset in the "formcreate" event.




procedure TPickingListFrame.FormCreate(Sender: TObject);
begin
   qOrders.Open;
end;
0
 
JeePeeTeeCommented:
Don't open on TPickingListFrame.FormCreate(Sender: TObject). Open during TPickingListFrame.FormShow(....

This will by-pass creation order issues as well.
0
 
kretzschmarCommented:
as the questioner itself didn't response to any comment which wass done, so that any advice due lack of feedback could be/ could not be right, i would recommend to delete this question

meikl ;-)
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.