Page 1 of 1

ado

Posted: 31.08.2005, 09:07
by guyvdb
Hello,

I have a problem with ADO.
We use delphi 7 and our database is SQL SERVER 2000.
If we use dblib, everything works fine.
Nevertheless, we want change to ADO.

The problem is with the next piece of code:

[syntax="delphi"]procedure TfrmIntrastats.fillGrditems(strSelect: string; strWhere: string);
var
r, i: integer;
begin
try
screen.Cursor := crSQLWait;
if not(chkAlleStatussen.Checked) then //status
strWhere := strWhere + ' and (intrastat.ic_status = 1)';
qryIntrastats.SQL.Text := strSelect + ' ' + strWhere;
if qryIntrastats.Active then
qryIntrastats.Close;
try
qryIntrastats.Open;
// recCount := qryIntrastats.recordcount;
grdIntrastats.WordWrap := true;
grdIntrastats.BeginUpdate;
grdIntrastats.RowCount := 1;
r := 1;
i := 1;
while not qryIntrastats.eof do
begin
if (i >= qryfrom) then
begin
grdIntrastats.AddRow;
grdIntrastats.ColumnByName['id'].rows[r] := qryIntrastats.Fields[0].AsString; //id
grdIntrastats.ColumnByName['code'].rows[r] := qryIntrastats.Fields[1].AsString; //code
grdIntrastats.ColumnByName['descriptionn'].Rows[r] := qryIntrastats.Fields[2].AsString; //nederlandse omschrijving
grdIntrastats.ColumnByName['descriptionf'].Rows[r] := qryIntrastats.Fields[3].AsString; //franse omschrijving
grdIntrastats.ColumnByName['descriptione'].Rows[r] := qryIntrastats.Fields[4].AsString; //engelse omschrijving
grdIntrastats.ColumnByName['dtcreaton'].Rows[r] := stod(qryIntrastats.Fields[5].AsString); //dtcreaton
grdIntrastats.ColumnByName['creatby'].Rows[r] := qryIntrastats.Fields[6].AsString; //creatby
grdIntrastats.ColumnByName['dtmodion'].Rows[r] := stod(qryIntrastats.Fields[7].AsString); //dtmodion
grdIntrastats.ColumnByName['modiby'].Rows[r] := qryIntrastats.Fields[8].AsString; //modiby
grdIntrastats.ColumnByName['updates'].Rows[r] := qryIntrastats.Fields[9].AsString; //updates
grdIntrastats.ColumnByName['status'].Rows[r] := qryIntrastats.Fields[10].AsString; //state

//set color
if (r mod 2) = 0 then
grdIntrastats.RowColor[r] := $00FBC4C4
else
grdIntrastats.RowColor[r] := clCream;
r := r + 1;
end;
i := i + 1;
if (i > qryto) then
break;
qryIntrastats.next;
end;
if qryIntrastats.Eof then
btnVolgende.Visible := false
else
btnVolgende.Visible := true;
qryIntrastats.Close;
grdIntrastats.AutoSizeRows(false,0);
// grdTeksten.AutoSize := true;
grdIntrastats.endUpdate;
setScrollButtons;
if (grdIntrastats.RowCount > 1) then
begin
if (selrow = 0) then
selrow := 1;
end;
except
on e:exception do
begin
if qryIntrastats.Active then qryIntrastats.Close;
logerror(e,'TfrmIntrastats.fillGrditems');
end;
end;
finally
screen.Cursor := crDefault;
end;
end;[/syntax]

We have tables with a lot of records.
So, the customer can specify how many rows he wants in the grid.
We do this in combination with a counter.
Again, with dblib it works fine.
With ADO, after calling the procedure several times, the program begins
to be slower, and finally crashes because there is no more memory left.

What can be the problem?

I tested this also with the demo version of sqlDirect in combination with ADO, without any problems.

greetings,

Guy

Posted: 31.08.2005, 09:27
by Michael
Hi guivdb,

I put your sourcecode into "code"-tags to increase the readability.

@all:
Please mark all your sourcecode you are about to post by using the "code"-tags. Thank you!

Posted: 12.09.2005, 17:54
by fduenas
and please
@all: specify also the ZeosVersion and if it s the latest from CVS, the CVS version has a lot of fixes reagarding to this kind of issues.

I think this is a memory leack with the ado protocol, but maybe is is now fixed when a bug with oracles cursors was found and fixed.
try to use latest version.

Posted: 13.09.2005, 07:54
by guyvdb
fduenas,

Thanks for your answer.

We are using version 6.5.1 (nov 2004).
We have a production application, so we can't
go directly to the latest cvs-version because of the
change they made in the query component 'requestlive vs readonly'

As soon as possible i will do a test with the latest version on another machine.

Gr.,

Guy

Posted: 13.09.2005, 18:03
by fduenas
Hi guyvdb: yes that could be the reason for you memory leak.
for replacing requestlive to readonly, using any multireplace program to find the matches 'requestlive=true' to 'readonly=false', use gexperts it has a usefultool to replace the 'dfm' files.

Any way you can still modify the updated ZAbstractRODataset sources to modify the properties names and behaviour ('true' instead of 'false'). i think it is better than working with old versions. or add a new property 'RequestLive' that will change 'ReadOnly' property to true when 'requestLive' is false. in this way you can still work with your project without changes.

Check th post i made recently: http://seegernet.koolhost.de/zeosforum/ ... c.php?t=67

Posted: 14.09.2005, 07:39
by guyvdb
Thanks a lot!

gr.,

Guy