ado
Posted: 31.08.2005, 09:07
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
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