你的主从关系是使用Master/Detail属性绑定的吗?

解决方案 »

  1.   

    procedure TFrmFoundBJ.BitBtn7Click(Sender: TObject);
    var
    str,str2,str3:string;
    begin
       str:='select name1,date1,Tableid2,state,state2,id  from sjyewuyuan  where name1='''+FrmMain.Edit2.Text+''' and  date1<= '''+Datetostr(DateTimePicker2.date)+''' and date1>= '''+Datetostr(DateTimePicker1.date)+''' and state=0  order by tableid2 ';
       str2:='select name1,date1,Tableid2,state,state2,id  from sjyewuyuan  where name1='''+FrmMain.Edit2.Text+''' and  date1<= '''+Datetostr(DateTimePicker2.date)+''' and date1>= '''+Datetostr(DateTimePicker1.date)+''' and state=1 and state2=0  order by tableid2 ';
       str3:='select name1,date1,Tableid2,state,state2,id  from sjyewuyuan  where name1='''+FrmMain.Edit2.Text+''' and  date1<= '''+Datetostr(DateTimePicker2.date)+''' and date1>= '''+Datetostr(DateTimePicker1.date)+''' and state2=1 order by tableid2 ';   if DateTimePicker1.Date<=DateTimePicker2.date then
          begin
           ADODataSet1.Close ;
           if RadioButton1.Checked =true then
              begin
                ADODataSet1.CommandText :=str;
              end;
           if RadioButton2.Checked =true then
                 begin
                   ADODataSet1.CommandText :=str2;
                 end;       if RadioButton3.Checked =true  then
              begin
                ADODataSet1.CommandText :=str3;
              end;
           ADODataSet1.Open ;
           DataSource1.DataSet :=ADODataSet1 ;
           DBGrid1.DataSource :=DataSource1;
          end
          else
          begin
             ShowMessage ('输入日期错误!');
             DateTimePicker1.SetFocus ;
             exit;
          end;
      

  2.   

    你编写的思路有问题;主从表通过query来配对,并且在赋值前给以变量检查和清空,
      后查询结果中要加入dbgrid刷新语句,
      

  3.   

    你的时间字段是时间类型吗?
    看看你的两个操作系统的时间格式是不是一样的
    最好都设置成长日期型'xxxx-xx-xx'