Показать сообщение отдельно
  #1  
Старый 22.04.2010, 16:27
Андреи4 Андреи4 вне форума
Прохожий
 
Регистрация: 22.04.2010
Сообщения: 5
Репутация: 10
По умолчанию Не добавляются записи

при выполнении кода, возникает ошибка, показанная на рисунке.
все таблицы связаны 1-1 по полю pupilId. таблицы pupil главная. не для каждой записи таблицы pupils есть соответствующая в таблице Disability. база в акцессе.
Код:
  Datamodule2.pupil.append;
  if family.Text<>#0 then
    datamodule2.pupil.FieldByName('sername').AsString:=Family.Text;
  if ima.Text<>#0 then
    datamodule2.pupil.FieldByName('Nam').AsString:=ima.Text;
  if otchestvo.Text<>#0 then
    datamodule2.pupil.FieldByName('Fname').AsString:=otchestvo.Text;
  datamodule2.pupil.FieldByName('Pol').AsString:=pol.Text;
  if birthday.Text<>da then
    datamodule2.pupil.FieldByName('Birthday').AsDateTime:=strtodate(birthday.Text);
  if adress.Text<>#0 then
    datamodule2.pupil.FieldByName('Adress').AsString:=(adress.Text);
  if phone.Text<>DT then
    datamodule2.pupil.FieldByName('Phone').AsString:=phone.Text;
  datamodule2.pupil.Post;

  datamodule2.school.Append;
  datamodule2.school.FieldByName('pupilid').AsInteger:=datamodule2.pupil.FieldByName('pupilid').AsInteger;
  if clas.text<>#0 then
    datamodule2.school.FieldByName('GodObuch').AsInteger:=strtoint(clas.Text);
  if osh.Text<>#0 then
    datamodule2.school.FieldByName('Class').AsInteger:=strtoint(osh.Text);
  datamodule2.school.FieldByName('progid').AsInteger:=progr.ItemIndex+1;
  datamodule2.school.FieldByName('formid').AsInteger:=forma.itemindex+1;
  if zachisl.text<>da then
    datamodule2.school.FieldByName('zach').AsDateTime:= Strtodate(zachisl.Text);
  if putevka.text<>#0 then
    datamodule2.school.FieldByName('putevka').AsString:=putevka.text;
  if pmpk.text<>Dt then
    datamodule2.school.FieldByName('pmpk').AsString:=pmpk.Text;
  if dz.text<>#0 then
    datamodule2.school.FieldByName('zabolevanie').AsString:=Dz.Text;
  datamodule2.school.FieldByName('disability').AsBoolean:=disability.Checked;
  datamodule2.school.FieldByName('logoped').AsBoolean:=logoped.Checked;
  datamodule2.school.FieldByName('GPD').AsBoolean:=gpd.Checked;
  datamodule2.school.FieldByName('ssd').AsBoolean:=ccd.Checked;
  datamodule2.school.Post;

  datamodule2.parents.Append;
  datamodule2.parents.FieldByName('pupilid').AsInteger:=datamodule2.pupil.FieldByName('pupilid').AsInteger;
  if momfio.Text=#0 then
    datamodule2.parents.FieldByName('mother').AsString:=momfio.Text;
  if momphone.Text=MT then
    datamodule2.parents.FieldByName('phoneMother').AsString:=momphone.Text;
  if dadfio.Text=#0 then
    datamodule2.parents.FieldByName('father').AsString:=dadfio.Text;
  if dadphone.Text=MT then
    datamodule2.parents.FieldByName('PhoneFather').AsString:=dadphone.Text;
  datamodule2.parents.Post;

  if disability.checked then
  begin
    datamodule2.disability.Append;
    datamodule2.disability.FieldByName('pupilid').AsInteger:=datamodule2.pupil.FieldByName('pupilid').AsInteger;
    if nomer.Text=#0 then
      datamodule2.disability.FieldByName('nospravki').AsString:=nomer.Text;
    if beg.Text=dt then
      datamodule2.parents.FieldByName('beg').AsString:=beg.Text;
  end;
Изображения
Тип файла: jpg error.JPG (26.5 Кбайт, 5 просмотров)
Ответить с цитированием