- Код: Выделить всё
procedure LoadTraining();
var d1, d2 : TDateTime;
idx : integer;
begin
DM.ibQExec.Close(); DM.ibQExec.SQL.Clear();
DM.ibQExec.SQL.Add('select * from sch_training');
DM.ibQExec.SQL.Add('order by id');
DM.ibQExec.Open();
while (not DM.ibQExec.Eof) do begin
d1 := DM.ibQExec.Fields.ByNameAsDate['date_begin'];
d2 := DM.ibQExec.Fields.ByNameAsDate['date_end'];
idx := DM.ibQExec.Fields.ByNameAsInteger['id'];
//ShowMessage(DateToStr(d1));
//ShowMessage(DateToStr(d2));
case (idx) of
1 : begin FMain.DateEdit3.Date := d1;//DM.ibQExec.Fields.ByNameAsDateTime['date_begin'];
FMain.DateEdit4.Date := d2;//DM.ibQExec.Fields.ByNameAsDateTime['date_end'];
end;
2 : begin FMain.DateEdit5.Date := d1;//DM.ibQExec.Fields.ByNameAsDateTime['date_begin'];
FMain.DateEdit6.Date := d2;//DM.ibQExec.Fields.ByNameAsDateTime['date_end'];
end;
3 : begin FMain.DateEdit13.Date := d1;//DM.ibQExec.Fields.ByNameAsDateTime['date_begin'];
FMain.DateEdit14.Date := d2;//DM.ibQExec.Fields.ByNameAsDateTime['date_end'];
end;
4 : begin FMain.DateEdit15.Date := d1;//DM.ibQExec.Fields.ByNameAsDateTime['date_begin'];
FMain.DateEdit16.Date := d2;//DM.ibQExec.Fields.ByNameAsDateTime['date_end'];
end;
5 : begin FMain.DateEdit25.Date := d1;//DM.ibQExec.Fields.ByNameAsDateTime['date_begin'];
FMain.DateEdit26.Date := d2;//DM.ibQExec.Fields.ByNameAsDateTime['date_end'];
end;
6 : begin FMain.DateEdit27.Date := d1;//DM.ibQExec.Fields.ByNameAsDateTime['date_begin'];
FMain.DateEdit28.Date := d2;//DM.ibQExec.Fields.ByNameAsDateTime['date_end'];
end;
7 : begin FMain.DateEdit29.Date := d1;//DM.ibQExec.Fields.ByNameAsDateTime['date_begin'];
FMain.DateEdit30.Date := d2;//DM.ibQExec.Fields.ByNameAsDateTime['date_end'];
end;
8 : begin FMain.DateEdit17.Date := d1;//DM.ibQExec.Fields.ByNameAsDateTime['date_begin'];
FMain.DateEdit18.Date := d2;//DM.ibQExec.Fields.ByNameAsDateTime['date_end'];
end;
9 : begin FMain.DateEdit19.Date := d1;//DM.ibQExec.Fields.ByNameAsDateTime['date_begin'];
FMain.DateEdit20.Date := d2;//DM.ibQExec.Fields.ByNameAsDateTime['date_end'];
end;
end;
DM.ibQExec.Next();
end;
end;
Если писать вот так, то ошибка вылетает на строке FMain.DateEdit4.Date :=......
case (idx) of
1 : begin FMain.DateEdit3.Date := DM.ibQExec.Fields.ByNameAsDateTime['date_begin'];
FMain.DateEdit4.Date := DM.ibQExec.Fields.ByNameAsDateTime['date_end'];
А если оставить как есть, то сообщение вылетает на DM.ibQExec.Next();
Еще раз повторюсь, что сообщение гласит о том что источник данных закрыт