Solved

Delphi 7 :: TADOQuery OnAfterScroll Error with parameters

Posted on 2007-11-27
12
1,206 Views
Last Modified: 2013-11-23
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

0
Comment
Question by:Marius0188
  • 3
  • 3
  • 2
  • +2
12 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 20363690
ensure, that the ParamCheck-property of the TAdoQuery is set to true

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 20363698
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
 
LVL 4

Expert Comment

by:JeePeeTee
ID: 20363862
Is your DBConnection and your qOrders/qPart opened at designtime? Close them before you launch you application.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 10

Expert Comment

by:dinilud
ID: 20363906
are you sure the error from "qOrdersAfterScroll" event
0
 
LVL 10

Expert Comment

by:dinilud
ID: 20363970
Change component creation order of these two components.
(qOrders,qParts)
0
 
LVL 10

Expert Comment

by:dinilud
ID: 20363998
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
 
LVL 4

Expert Comment

by:JeePeeTee
ID: 20364018
Don't open on TPickingListFrame.FormCreate(Sender: TObject). Open during TPickingListFrame.FormShow(....

This will by-pass creation order issues as well.
0
 
LVL 21

Accepted Solution

by:
developmentguru earned 500 total points
ID: 20365253
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 20617343
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
 
LVL 1

Expert Comment

by:Computer101
ID: 21197650
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question