Reputation: 12059
I have to do some work on a legacy Delphi 7 application and wanted to switch from ADO
components to dbExpress
but it gives me a strange problem.
The setup is simple
when I use ADO
I have this
ADOConnection
ADOQuery
DataSetProvider
ClientDataSet
DataSource
DBGrid
when executing a query that returns about 50000 rows there are no problems.
I can scroll to the last row, no problems occur
Now when I use dbExpress
I have the following setup.
Note that I only switched the first 2 components, all the other remain unchanged.
SQLConnection
SQLQuery
DataSetProvider
ClientDataSet
DataSource
DBGrid
Executing the same query works, and it opens faster.
But I cannot scroll to the last row anymore, if I try to do that I get the error
Insufficient memory for this operation
In both cases I use the exact same code
ClientDataSet1.Open;
There are no events coupled to any of the components.
In fact I made a small test project with nothing in it but these components, and it still gives the same error. So its easy reproducable.
How is it possible that the ClientDataSet is able to hold all 50000 rows when using ADO
, but not when using dbExpress
?
How can I get around this ?
As requested, here is the complete code of the sample project (I left out the persistent fields to keep it a bit smaller)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBClient, Provider, ADODB, StdCtrls, DBCtrls, Grids,
DBGrids, ExtCtrls, DBXpress, FMTBcd, SqlExpr;
type
TForm1 = class(TForm)
Panel1: TPanel;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
Button1: TButton;
Button2: TButton;
DataSetProvider1: TDataSetProvider;
ClientDataSet1: TClientDataSet;
DataSource1: TDataSource;
Label1: TLabel;
SQLConnection1: TSQLConnection;
SQLQuery1: TSQLQuery;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ClientDataSet1.Open;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ClientDataSet1.Close;
end;
end.
And the DFM (I left out the persistent fields to keep it a bit smaller)
object Form1: TForm1
Left = 347
Top = 125
Width = 1305
Height = 675
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 0
Width = 1289
Height = 97
Align = alTop
Caption = 'Panel1'
TabOrder = 0
object Label1: TLabel
Left = 240
Top = 32
Width = 32
Height = 13
Caption = 'Label1'
end
object DBNavigator1: TDBNavigator
Left = 16
Top = 64
Width = 240
Height = 25
DataSource = DataSource1
TabOrder = 0
end
object Button1: TButton
Left = 32
Top = 24
Width = 75
Height = 25
Caption = 'connect'
TabOrder = 1
OnClick = Button1Click
end
object Button2: TButton
Left = 112
Top = 24
Width = 75
Height = 25
Caption = 'disconnect'
TabOrder = 2
OnClick = Button2Click
end
end
object DBGrid1: TDBGrid
Left = 0
Top = 97
Width = 1289
Height = 539
Align = alClient
DataSource = DataSource1
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object DataSetProvider1: TDataSetProvider
DataSet = SQLQuery1
Left = 512
Top = 328
end
object ClientDataSet1: TClientDataSet
Aggregates = <>
PacketRecords = 50
Params = <>
ProviderName = 'DataSetProvider1'
Left = 512
Top = 392
end
object DataSource1: TDataSource
DataSet = ClientDataSet1
Left = 528
Top = 456
end
object SQLConnection1: TSQLConnection
ConnectionName = 'MSSQLConnection'
DriverName = 'MSSQL'
GetDriverFunc = 'getSQLDriverMSSQL'
LibraryName = 'dbexpmss.dll'
LoginPrompt = False
Params.Strings = (
'DriverName=MSSQL'
'HostName=XXXXXX'
'DataBase=GTT_Test'
'User_Name=XXX'
'Password=XXX'
'BlobSize=-1'
'ErrorResourceFile='
'LocaleCode=0000'
'MSSQL TransIsolation=ReadCommited'
'OS Authentication=False')
VendorLib = 'oledb'
Left = 584
Top = 208
end
object SQLQuery1: TSQLQuery
MaxBlobSize = -1
Params = <>
SQL.Strings = (
'select * from vwRitComplete')
SQLConnection = SQLConnection1
Left = 584
Top = 272
end
end
Upvotes: 0
Views: 308