如何在dbgrid里从数据库中显示7天的记录
请教朋友们:
下面的代码为什么实现不了上面的功能?
procedure TExamForm.postbitbtnClick(Sender: TObject);
begin
examtb.Open ;
//examtb.Insert ;
examtb.FieldByName('exam_time').AsDateTime :=date;
examtb.Post ;
end;
procedure TExamForm.DateTimePicker1Change(Sender: TObject);
var
date1,date2:tdate;
begin
//try
with examquery do
begin
SQL.Clear ;
//Params.AddParam('date1').Value :=(datetimepicker1.date);
//Params.parambyname('date2').Value :=(datetimepicker1.date-7);
SQL.Add('select examwords.user_name,examwords.words from examwords,enterwords where examwords.words=enterwords.words' );
SQL.Add('and first_time< ' +datetostr(datetimepicker1.date)+ ' and exam_time>' + datetostr(datetimepicker1.date-7));
Prepare ;
Open ;
examdbgrid.Columns.Items[0].Title.caption :=examtb.Fields[0].FieldName;
examdbgrid.Columns.Items[1].Title.caption:=examtb.Fields[1].FieldName;
examdbgrid.Columns.Items[2].Title.caption:=examtb.Fields[2].FieldName;
examdbgrid.Columns.Items[3].Title.caption:=examtb.Fields[3].FieldName;
examtb.Open ;
examtb.Edit ;
examtb.Append;
examdbgrid.Enabled :=true;
//for (select words from examwords to :exam_means) do
//except
//showmessage('open table error!');
//raise;
//enablecontrols;
end;
//end;
问题点数:20、回复次数:5Top




