what i usually do is construct the query
in in a TSTringList first so your

SQL.Add ('select');
SQL.Add ('from');
SQL.Add ('customers');

becomes


with SQLSTrings
do begin
   Add ('select');
   Add ('from');
   Add ('customers');
end;

SQL.assign(SQLStrings);

so you only get the server ping once at the end.



But - in any case - I'm not 100% sure but I don't think
the server calls you observe are "prepares" - i think they are
"unprepares".   They occur when you change the text of a query
to notify that a prepare is required.

The prepare doesn't occur until you Execute the query.   If you
haven't prepared it yourself explicitly, it will do it for you
when you Open or Execute the query.

If I'm right about this it might not be too big a worry
because while prepares can be resource intensive a simple
unprepare notification probably isn't.    It's still network
traffic but not all the overhead of constructing a query
plan each time.


ns





-----Original Message-----
From: Alex Kouznetsov <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Date: Tuesday, 19 September 2000 18:04
Subject: [DUG]: Wow ! Every TADOQuery.SQL changing at run-time causes
separate sp_prepare call


Am I crazy ? Am I doing something wrong ?

I have just accidentally found, that whenever SQL property of TADOQuery
changes, there is a separate stored procedure call sent to SQL server.

It can be seen via SQL Server Profiler.

Whenever either SQL.Add is used or SQL.Text  is changed in any way, there is
a call looking like "sp_prepare @p1 output etc.."

If I do

SQL.Add ('select');
SQL.Add ('from');
SQL.Add ('customers');

then there will be 3 calls to sp_prepare !!!

I generate long sql statements in loops and get tonns of  this sent to the
server.

I found that these calls do not occur if ParamCheck property of ADOQuery is
set to FALSE ! But then ':' style parameters do not get recognized by ADO
and they all have to be somehow manually created.

Does anyone have any suggestions,comments,ideas on this ?

Regards
Alex



---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to