was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

36 Visitors Online


 
...das Ergebnis eines TQuery in einer Tabelle übertragen?
Autor: Wayne Hill
[ Tip ausdrucken ]  

Tip Bewertung (5):  
     


//------------------------------------------

unit Unit1;

interface

uses
  
Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms,
  Dialogs, StdCtrls, Grids, DBGrids, DB, DBTables;

type
  
TForm1 = class(TForm)
    Button1: TButton;
    Query1: TQuery;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    procedure Button1Click(Sender: TObject);
  private
    
{ Private declarations }
  
public
    
{ Public declarations }
  
end;

var
  
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  
InitQuery: TQuery;
  InitTable: TTable;
  InitBatch: TBatchMove;
begin
  
InitQuery := TQuery.Create(Application);
  with InitQuery do
  begin
    
DatabaseName := 'DBDEMOS';
    Close;
    SQL.Clear;
    SQL.Add('SELECT * ');
    SQL.Add('FROM customer.db');
    SQL.Add('WHERE Country="US"');
    SQL.SaveToFile('mgrInit.sql');
    try
      
Open;
      try // Send the SQL result to c:\temp\INIT.DB
        
InitTable := TTable.Create(Application);
        with InitTable do 
        begin 
          
DatabaseName := 'c:\temp';
          TableName    := 'INIT';
        end;
        InitBatch := TBatchMove.Create(Application);
        with InitBatch do 
        begin
          
Destination := InitTable;
          Source      := InitQuery;
          Mode        := batCopy;
          Execute;
        end;
      finally
        
InitTable.Free;
        InitBatch.Free;
      end;
    except
      
Free;
      Abort;
    end;
    Free;
  end;
end;

end.

//-------------------------


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners