M
mytouching
Unregistered / Unconfirmed
GUEST, unregistred user!
各位富翁好,在下是一名delphi的初学者,也是一位爱好者。
我昨天碰到了一个这样的问题,我想用DateTimePicker控件来直接选择查询的
日期,然后通过点击“查询”按钮来实现查询功能。但始终未能成功,以下是我写
的代码,可能错误太多,望富翁莫耻笑!(我用的d6和paradox)
procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
begin
DateTimePicker1.Date:=query1.fieldbyname('riqi').Value;
end;
procedure TForm1.DataSource1UpdateData(Sender: TObject);
begin
DateTimePicker1.Date:=query1.fieldbyname('riqi').Value;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sdate:string;
begin
sdate:='';
query1.Close;
query1.SQL.Clear;
query1.FieldByName('riqi').Asstring:=datetostr(DateTimePicker1.Date);
sdate:=query1.FieldByName('riqi').Asstring;
query1.SQl.Add('Select'+sdate);
query1.SQl.Add('select * FROM shiyan');
query1.Prepare;
query1.Open;
end;
procedure TForm1.DateTimePicker1Click(Sender: TObject);
begin
DataSource1.OnDataChange:=nil;
query1.Edit;
end;
我昨天碰到了一个这样的问题,我想用DateTimePicker控件来直接选择查询的
日期,然后通过点击“查询”按钮来实现查询功能。但始终未能成功,以下是我写
的代码,可能错误太多,望富翁莫耻笑!(我用的d6和paradox)
procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
begin
DateTimePicker1.Date:=query1.fieldbyname('riqi').Value;
end;
procedure TForm1.DataSource1UpdateData(Sender: TObject);
begin
DateTimePicker1.Date:=query1.fieldbyname('riqi').Value;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sdate:string;
begin
sdate:='';
query1.Close;
query1.SQL.Clear;
query1.FieldByName('riqi').Asstring:=datetostr(DateTimePicker1.Date);
sdate:=query1.FieldByName('riqi').Asstring;
query1.SQl.Add('Select'+sdate);
query1.SQl.Add('select * FROM shiyan');
query1.Prepare;
query1.Open;
end;
procedure TForm1.DateTimePicker1Click(Sender: TObject);
begin
DataSource1.OnDataChange:=nil;
query1.Edit;
end;