Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Code: Using a Server Query to Fill a Local Memory Table
Wed, Aug 9 2006 11:11 AMPermanent Link

"Johnnie Norsworthy"
I just wanted to share my code for copying a server query to a local memory
table. I use this code extensively for populating Developer Express Quantum
Grids.

All of the exception handling is done around the method calling code. I have
this method located in a centralized data module which includes all my
different session and database components.

I hope others find this useful. I do not know of any way to make this
faster, but I'm open for suggestions. I can populate a large grid from a
server in less than a second in most cases.

-Johnnie


procedure ServerQueryToLocalMemoryTable(var ServerQuery: TDBISAMQuery;
   var LocalMemoryTable: TDBISAMTable);
var
 MemoryStream: TMemoryStream;
begin
 MemoryStream := TMemoryStream.Create;
 try
   ServerQuery.RequestLive := True; // does not create table on server
   ServerQuery.Open;
   ServerQuery.SaveToStream(MemoryStream);
   // check to see if reloading or creating a new memory table
   if LocalMemoryTable.Exists then
   begin
     LocalMemoryTable.Close;
     LocalMemoryTable.EmptyTable;
   end
   else
   begin
     LocalMemoryTable.FieldDefs.Assign(ServerQuery.FieldDefs);
     LocalMemoryTable.CreateTable;
   end;
   ServerQuery.Close;
   LocalMemoryTable.LoadFromStream(MemoryStream);
 finally
   FreeAndNil(MemoryStream);
 end;
end;

Fri, Aug 11 2006 1:43 AMPermanent Link

Oliver Bock
Johnnie Norsworthy wrote:
> I just wanted to share my code for copying a server query to a local memory
> table. I use this code extensively for populating Developer Express Quantum
> Grids.
>...
>       LocalMemoryTable.FieldDefs.Assign(ServerQuery.FieldDefs);
>       LocalMemoryTable.CreateTable;

Is the above step necessary?  I thought LoadFromStream would create the
table and structure for you.


  Oliver
Fri, Aug 11 2006 12:04 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Oliver,

<< Is the above step necessary?  I thought LoadFromStream would create the
table and structure for you. >>

Nope, you need to create the table first.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image