Alex

3 things

firstly
>     // connection is assigned inside the constructor
I'm not abs sure this will work - assignment of the connection may require
the
component fully functional


secondly
Are you running this on an MS SQL 7 Server - If so run a trace and find out
how far thru the
compile SQL process you are getting.

Basically the ADOQuery replaces your parameter names with ? and passes it to
ADO for
compilation (This is how ADO parameters get 'typed')

Thirdly
Do you have any books on ADO - Programming ADO from M$ press is a must

HTH
Neven

----- Original Message -----
From: Alex Kouznetsov <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Sent: Wednesday, 27 September 2000 20:40
Subject: [DUG]: Strange database locks with ADO/MSSQL7


> Hi
>
> >From time to time I encounter strange kind of database locks while using
> Delphi/ADO/MSSQL7.
>
> In one case I found that the reason for the lock was incorrect SQL
statement
> (something like 'wherecode = ...', ie. missing space). I was getting no
> exception, just a table was staying locked until some other DB activity
was
> in place.
>
> I had another locking problem while just doing lots of different things
with
> the same Query. Eg. Set SQL,Open,Close,Set another SQL,ExecSQL,set another
> SQL,open,Close etc. This one got misteriously fixed by applying
> BeginTransaction and EndTransaction respectively at the beginning and the
> end of this chain of Open and ExecSQL statements.
>
> Latest example is another mistery.
>
> Here it is  (please note, in this example query does not even get open):
>
>   with TMyADOQuery.Create(Nil) do begin
>     // connection is assigned inside the constructor
>     SQL.Text := 'select * from mytable where ' +
>                 '((fromdate is NULL) or (fromdate <= :today1))'+
>                 ' and '+
>                 '((tilldate is NULL) or (tilldate >= :today2))';
>     // deliberately do not do anything else here in this example,
>     // assigning of the string above to SQL.Text is _enough_ !!! I have
> tested.
>     Free;
>   end;
>
> After this I do simple select query from another table which returns no
> results, and after that I log that "no result" event into the 3rd table.
> That logging (simple insert statement)  fails with the timeout.
>
> To solve the problem I simplify SQL statement to SQL.Text := 'select *
from
> mytable'. And I have no locking problem !!!
>
> Sometimes it seems to me that ADO has bugs in parameters area, sometimes
it
> seems to me that it does not work well when TADOQuery components created
in
> code and immidiatelly worked with. But these are just my guesses.
>
> Did anyone experienced anythig like 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