Re: ADOQuery Command Text does not return a result set



Hi Leposava,

I have this code
ADOQ2.Active:=False;
ADOQ2.Close;
ADOQ2.SQL.Clear;
sqlFill := '';
sqlFill := ('UPDATE Izpisi ');
sqlFill := sqlFill+(' Set DATA = '''+AdoTable1.FieldByName('data').AsString+'''' );
sqlFill := sqlFill+('WHERE IZPISTIP = 1');
ADOQ2.SQL.Add(sqlFill);
ADOQ2.ExecSQL;

This will execute the query, once, and not expecting a result set.

ADOQ2.Active:=True;

This will re-execute the query again, expecting a result set.
You should not set Active to True (or False again) when using with UPDATE (or INSERT/DElETE) commands that to not return result sets. ExecSQL is enough, although you can also use the Execute method of the TADOConnection component (without the need of a TADOQuery component).

Groetjes,
Bob Swart

--
Bob Swart Training & Consultancy (eBob42.com) Forever Loyal to Delphi
CodeGear Technology Partner -- CodeGear RAD Studio Reseller (BeNeLux)
Delphi Win32 & .NET books on Lulu.com: http://stores.lulu.com/drbob42
Personal courseware + e-mail support http://www.ebob42.com/courseware
Blog: http://www.drbob42.com/blog - RSS: http://eBob42.com/weblog.xml
.



Relevant Pages