Using a SQL command on a Virtual Table

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 1
Joined: Sat 20 Jun 2009 03:47
Location: USA

Using a SQL command on a Virtual Table

Post by FrankT » Fri 25 Mar 2011 10:30

Hi all,

I am using the Virtual Table Component from SQL Server DAC for Delphi / C++ Builder 2010 and I would like to use a Select statement on the data in that table, something like Select * from VirtualTable1 WHERE ID = 1. Since there is no connection to an external database, none of the standard SQL Query components will work with it.

Is there a way to use standard SQL commands with or without a SQL Query Component on the data in this Virtual Table and if so can someone Please explain how to do it.

Thank You,



Post by AndreyZ » Mon 28 Mar 2011 08:51


You cannot use SQL queries for the TVirtualTable component. You can use the TCRBatchMove component to extract data from the TVirtualTable component in the following way:

Code: Select all

VirtualTable1.AddField('id', ftInteger);
VirtualTable1.AddField('name', ftString, 10);
VirtualTable1.AppendRecord([1, 'n1']);
VirtualTable1.AppendRecord([1, 'n2']);
VirtualTable1.AppendRecord([2, 'n3']);
VirtualTable1.AppendRecord([2, 'n4']);
VirtualTable1.AppendRecord([2, 'n5']);
VirtualTable1.Filter := 'id=2';
VirtualTable1.Filtered := True;

VirtualTable2.AddField('id', ftInteger);
VirtualTable2.AddField('name', ftString, 10);
CRBatchMove.Source := VirtualTable1;
CRBatchMove.Destination := VirtualTable2;
VirtualTable1.Filtered := False;
You can use any dataset descendant component instead of VirtualTable2 to unload data to it from the TVirtualTable component.

Post Reply