Re: ADOQuery Command Text does not return a result set



Hi

although you can also use the Execute method of the
TADOConnection component (without the need of a TADOQuery component).

when I use ADOConnection1.Execute('UPDATE Izpisi Set DATA =
'''+SourceString+''', NAZIVIZP = ''Promet enega delavca'' WHERE IZPISTIP =
1');

it doesnt save S as it is instead of 'S' it writes 'L?' what is the
problem ? by the way here is the full procedure


procedure TForm1.Button7Click(Sender: TObject);
var
SourceString: string;
MemoryStream: TMemoryStream;
sqlFill:String;
begin

frxReport2.DesignReport;
//MemoryStream := TMemoryStream.Create;
MemoryStream:= TMemoryStream.Create;

try

//SourceString:= 'Leposava';
// frxReport1.Designer.Report.SaveToStream(StringStream);
frxReport2.SaveToStream(MemoryStream);
MemoryStream.Position := 0;

SetLength(SourceString, MemoryStream.Size);
MemoryStream.ReadBuffer(Pointer(SourceString)^, MemoryStream.Size);
finally
MemoryStream.Free;
end;

showmessage(SourceString);


ADOConnection1.Execute('UPDATE Izpisi Set DATA =
'''+SourceString+''', NAZIVIZP = ''Promet Senega delavca'' WHERE IZPISTIP =
1');


end;



"Bob Swart" <Bob@xxxxxxxxxx> wrote in message
news:4836B84C.1080507@xxxxxxxxxxxxx
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


.


Quantcast