ADO SQL delete 日期条件参数

unit Unit1;



interface



uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, DB, ADODB, Grids, DBGrids;



type

  TForm1 = class(TForm)

    Button1: TButton;

    ADOQuery1: TADOQuery;

    Memo1: TMemo;

    DBGrid1: TDBGrid;

    DataSource1: TDataSource;

    Button2: TButton;

    procedure Button1Click(Sender: TObject);

    procedure Button2Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;



var

  Form1: TForm1;



implementation



var

  tfdate: string;



{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);

const

  FROMWhereStr = ' from tbtest WHERE tfDate=:tfDate';

  ParamBuyDateTime = 'tfDate';

begin

  ADOQuery1.SQL.Text := 'select * ' + FROMWhereStr ;

  ADOQuery1.Parameters.ParamByName(ParamBuyDateTime).Value := '2015-05-15 20:34:00';

  ADOQuery1.Open;

  Memo1.Lines.Add( ADOQuery1.Parameters.ParamByName(ParamBuyDateTime).Value +  '' +  IntToStr(ADOQuery1.RecordCount));

end;



procedure TForm1.Button2Click(Sender: TObject);

const

  FROMWhereStr = ' from tbtest WHERE tfDate < #2015-05-15 20:34:00#';

  ParamBuyDateTime = 'tfDate';

begin

  ADOQuery1.SQL.Text := 'select * ' + FROMWhereStr ;

  ADOQuery1.Open;

  Memo1.Lines.Add( ADOQuery1.SQL.Text +  '' +  IntToStr(ADOQuery1.RecordCount));

end;





end.

 

你可能感兴趣的:(delete)