Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Delphi программирование > БД в Delphi
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 03.06.2017, 19:28   #1
Дэдпул
Пользователь
 
Регистрация: 28.04.2016
Сообщений: 34
По умолчанию Ошибка Перенос sql в акссес Delphi

procedure getinfo.
Код:
procedure tform5.getinfo;
var str:string; i,j,q:integer;
begin
 post.Active:=false;
 post.Filtered:=false;
 str:='';
 str:=datetostr(curdat.date);
 post.CommandText:='set dateformat dmy select resolution.rid, resolution.rregnum, resolution.rtotime, organs.oname, res_givers.rgfname from resolution, organs, res_givers where resolution.rtodate='+quotedstr(str)+
                   ' and resolution.rrgid=res_givers.rgid and res_givers.rgorg=organs.oid order by rtotime';
 post.Active:=true;       // все постановления с текущей датой исполнения
 if post.RecordCount>0 then data.RowCount:=post.RecordCount+1
  else data.RowCount:=post.RecordCount+2;
 for i:=1 to data.RowCount do
  data.Rows[i].Clear;
 data.Cells[0,0]:='Номер';
 data.Cells[1,0]:='Время';
 data.Cells[2,0]:='Куда';
 data.Cells[3,0]:='Кому';
 data.Cells[4,0]:='Сколько';
 data.Cells[5,0]:='Исполнитель';
 qpriv.Caption:=inttostr(post.RecordCount);
   oupdsniki.Active:=false;
   oupdsniki.CommandText:='select soldiers.sfname, resolution.rid from soldiers, who_whom_why, resolution where resolution.rid=who_whom_why.wwwrid and who_whom_why.wwwsid=soldiers.sid';
   oupdsniki.Active:=true;
   bludi.Active:=false;
   bludi.CommandText:='select peoples.pfname, resolution.rid from peoples, who_why, resolution where peoples.pid=who_why.wwpid and who_why.wwrid=resolution.rid';
   bludi.Active:=true;

 for i:=1 to post.RecordCount do
  begin
   bludi.Filtered:=false;
   bludi.Filter:='rid='+quotedstr(post.Recordset.Fields[0].get_value());
   bludi.Filtered:=true;
   q:=bludi.RecordCount;
   oupdsniki.Filtered:=false;
   oupdsniki.Filter:='rid='+quotedstr(post.Recordset.Fields[0].get_value());
   oupdsniki.Filtered:=true;
   str:='';
   for j:=1 to oupdsniki.RecordCount do
    begin
     str:=str+oupdsniki.Recordset.Fields[0].get_value()+' ';
     oupdsniki.Next
    end;


//
//   cr.CommandText:='insert into tmp values('+quotedstr(post.Recordset.Fields[1].get_value())+', '+quotedstr(post.Recordset.Fields[2].get_value())+', '+quotedstr(post.Recordset.Fields[3].get_value())+', '+quotedstr(post.Recordset.Fields[4].get_value())+', '+quotedstr(inttostr(q))+', '+quotedstr(str)+')';
//   cr.Execute;

   data.Cells[0,i]:=post.Recordset.Fields[1].get_value();
//   dtp.date:=post.Recordset.Fields[2].get_value();
   data.Cells[1,i]:=timetostr(post.Recordset.Fields[2].get_value());
   data.Cells[2,i]:=post.Recordset.Fields[3].get_value();
   data.Cells[3,i]:=post.Recordset.Fields[4].get_value();
   data.Cells[4,i]:=inttostr(q);
   data.Cells[5,i]:=str;


   post.Next
  end;
// adt.Active:=false;
// adt.Active:=true;

end;
Ребят помогите с процедурой.На sql этот код работал.После переноса дает ошибку.Точно знаю из за этого места
Код:
post.Active:=false;
 post.Filtered:=false;
 str:='';
 str:=datetostr(curdat.date);
 post.CommandText:='set dateformat dmy select resolution.rid, resolution.rregnum, resolution.rtotime, organs.oname, res_givers.rgfname from resolution, organs, res_givers where resolution.rtodate='+quotedstr(str)+
                   ' and resolution.rrgid=res_givers.rgid and res_givers.rgorg=organs.oid order by rtotime';
 post.Active:=true;
Нужно Дату и время как то отдельно прописать.Ребята советовали тут но не то(все равно кидает ошибку) .С этим проблему решил.

Последний раз редактировалось Дэдпул; 04.06.2017 в 00:24.
Дэдпул вне форума Ответить с цитированием
Старый 04.06.2017, 00:37   #2
Дэдпул
Пользователь
 
Регистрация: 28.04.2016
Сообщений: 34
По умолчанию

Теперь другое
Код:
var
  Form6: TForm6;

implementation

uses pds5, pds1, ADOInt;

{$R *.dfm}

procedure tform6.getpdat;
var i:integer;
begin
 peop.Cells[0,0]:='Ôàìèëèÿ';
 peop.Cells[1,0]:='Èìÿ';
 peop.Cells[2,0]:='Îò÷åñòâî';
 peop.Cells[3,0]:='Ñòàòóñ';
 peop.Cells[4,0]:='Äîñòàâëåí';
 peop.Cells[5,0]:='Îáñòîÿòåëüñòâà';
 peop.Cells[6,0]:='Ñèëà';
 cres.Filtered:=false;
 if res.cells[0,res.row]='' then
  begin
   peop.RowCount:=2;
   peop.Rows[1].Clear;
   exit
  end;
 cres.Filter:='rregnum='+quotedstr(res.Cells[0,res.Row]);
 cres.Filtered:=true;
 //cres.first;
 pm.Active:=false;
 pm.filtered:=false;
 pm.CommandText:='select peoples.pid, peoples.pfname, peoples.pnname, peoples.poname, stat.sname from peoples, who_why, stat where who_why.wwrid='+quotedstr(cres.Recordset.Fields[0].get_value())+' and peoples.pid=who_why.wwpid and who_why.wwsid=stat.sid';
 pm.Active:=true;
 if pm.RecordCount=0 then peop.RowCount:=pm.RecordCount+2
  else peop.RowCount:=pm.RecordCount+1;

 pp.Active:=false;
 pp.CommandText:='select who_when.wwpid, reasons.rtype, influence.itype from who_when, influence, reasons where who_when.wwrid='+quotedstr(cres.Recordset.Fields[0].get_value())+' and who_when.wwiid=influence.iid and who_when.wwwhy=reasons.rid';
 pp.Active:=true; 

 for i:=1 to pm.RecordCount do
  begin
   peop.Cells[0,i]:=pm.Recordset.Fields[1].get_value();
   peop.Cells[1,i]:=pm.Recordset.Fields[2].get_value();
   peop.Cells[2,i]:=pm.Recordset.Fields[3].get_value();
   peop.Cells[3,i]:=pm.Recordset.Fields[4].get_value();

   pp.Filtered:=false;
   pp.Filter:='wwpid='+quotedstr(pm.Recordset.Fields[0].get_value());
   pp.Filtered:=true;
   if pp.RecordCount=1 then
    begin
     if pp.Recordset.Fields[1].get_value()='íå âîçíèêëî' then peop.Cells[4,i]:='Äà'
      else peop.Cells[4,i]:='Íåò';
     peop.Cells[5,i]:=pp.Recordset.Fields[1].get_value();
     peop.Cells[6,i]:=pp.Recordset.Fields[2].get_value()
    end;
   pp.Filtered:=false;
   pm.Next
  end;

end;

procedure tform6.getresdat;
var i:integer; st:string;
tdate1 : TDateTime;
begin
cres.Active:=false;
 cres.Filtered:=false;
 st:=datetostr(dat.date);
 cres.CommandText:='select resolution.rid, resolution.rregnum, resolution.rrgid, res_givers.rgfname, res_givers.rgnoname, organs.oname, resolution.rprice from resolution, res_givers, organs where int (resolution.rtodate)=:date '+' and resolution.rrgid=res_givers.rgid and res_givers.rgorg=organs.oid';
 cres.Parameters.ParamByName('date').DataType := ftDate;
 tdate1 := Trunc(dat.date);
 cres.Parameters.ParamByName('date').Value := tdate1;
 cres.Active:=true;
 if cres.RecordCount=0 then res.RowCount:=cres.RecordCount+2
  else res.RowCount:=cres.RecordCount+1;
 for i:=1 to res.RowCount do
  res.Rows[i].Clear;
 res.Cells[0,0]:='Íîìåð';
 res.Cells[1,0]:='Êóäà';
 res.Cells[2,0]:='Êîìó';
 res.Cells[3,0]:='Ðàñõîäû';
 for i:=1 to cres.RecordCount do
  begin
   res.Cells[0,i]:=cres.Recordset.Fields[1].get_value();
   res.Cells[2,i]:=cres.Recordset.Fields[3].get_value()+' '+cres.Recordset.Fields[4].get_value();
   res.Cells[1,i]:=cres.Recordset.Fields[5].get_value();
   res.Cells[3,i]:=cres.Recordset.Fields[6].get_value();
   cres.Next
  end;
 getpdat
end;

procedure TForm6.CheckBox1Click(Sender: TObject);
begin
 if checkbox1.Checked then
  begin
   cool.Visible:=true;
   why.Visible:=false;
   wh.Visible:=false;
   wh.Text:='Äîñòàâëåí'
  end
  else
   begin
    cool.Visible:=false;
    why.Visible:=true;
    wh.Visible:=true;
    wh.Text:='';
   end
end;

procedure TForm6.contrClick(Sender: TObject);
begin
 if contr.Checked then
  begin
   fr.Visible:=true;
   force.Visible:=true;
   force.Text:=''
  end
  else
   begin
    fr.Visible:=false;
    force.Visible:=false;
    force.Text:='íå ïðèìåíÿëîñü'
   end
end;

procedure TForm6.resSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
 getpdat
end;

procedure TForm6.FormShow(Sender: TObject);
var t:systemtime; i,j:integer; str:string;
begin
 ToolButton4Click(form6);
 all.Active:=false;
 all.CommandText:='select * from reasons';
 all.Active:=true;
 wh.Items.Clear;
 for i:=1 to all.RecordCount do
  begin
   wh.Items.Add(all.Recordset.Fields[1].get_value());
   all.Next
  end;
 force.Items.Clear;
 all.Active:=false;
 all.CommandText:='select * from influence';
 all.Active:=true;
 for i:=1 to all.RecordCount do
  begin
   force.Items.Add(all.Recordset.Fields[1].get_value());
   all.Next
  end;
 getsystemtime(t);
 str:=inttostr(t.wDay)+'.'+inttostr(t.wMonth)+'.'+inttostr(t.wYear);
 dat.Date:=strtodate(str);
 getresdat
end;

procedure TForm6.datChange(Sender: TObject);
begin
 getresdat
end;

procedure TForm6.resKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var i:integer;
begin
 toolbutton2click(form6);
 for i:=1 to peop.RowCount do
  peop.Rows[i].Clear;
 getpdat
end;

procedure TForm6.resClick(Sender: TObject);
var i:integer;
begin
 toolbutton2click(form6);
 for i:=1 to peop.RowCount do
  peop.Rows[i].Clear;
 getpdat
end;

procedure TForm6.ToolButton2Click(Sender: TObject);
begin
 checkbox1.Checked:=false;
 cool.Visible:=false;
 wh.Visible:=true;
 wh.Text:='';
 contr.Checked:=false;
 force.Visible:=false;
 force.Text:='íå ïðèìåíÿëîñü';
 fr.Visible:=false
end;

procedure TForm6.ToolButton1Click(Sender: TObject);
var t:systemtime; str:string;
begin
 getsystemtime(t);
 str:=inttostr(t.wDay)+'.'+inttostr(t.wMonth)+'.'+inttostr(t.wYear);
 cres.Filtered:=false;
 cres.Filter:='rregnum='+quotedstr(res.Cells[0,res.Row]);
 cres.Filtered:=true;
 pm.Filtered:=false;
 pm.Filter:='pfname='+quotedstr(peop.Cells[0,peop.Row])+' and pnname='+quotedstr(peop.Cells[1,peop.Row])+' and poname='+quotedstr(peop.Cells[2,peop.Row]);
 pm.Filtered:=true;
 rea.Active:=true;
 rea.Filtered:=false;
 rea.Filter:='rtype='+quotedstr(wh.Text);
 rea.filtered:=true;
 if rea.RecordCount=0 then
  begin
   ins.CommandText:='insert into reasons (rtype) values('+quotedstr(wh.Text)+')';
   ins.Execute;
   rea.Active:=false;
   rea.Active:=true
  end;
 inf.Active:=true;
 inf.Filtered:=false;
 inf.Filter:='itype='+quotedstr(force.Text);
 inf.filtered:=true;
 if inf.RecordCount=0 then
  begin
   ins.CommandText:='insert into influence (itype) values('+quotedstr(force.Text)+')';
   ins.Execute;
   inf.Active:=false;
   inf.Active:=true
  end;
 all.Active:=false;
 all.CommandText:='select * from who_when where wwrid='+quotedstr(cres.Recordset.Fields[0].get_value())+' and wwpid='+quotedstr(pm.Recordset.Fields[0].get_value());
 all.Active:=true;
 if all.RecordCount=0 then
  begin
   ins.CommandText:='insert into who_when (wwrid,wwpid,wwdate,wwiid,wwwhy)values('+quotedstr(cres.Recordset.Fields[0].get_value())+','+quotedstr(pm.Recordset.Fields[0].get_value())+','+quotedstr(str)+','+quotedstr(inf.Recordset.Fields[0].get_value())+','+quotedstr(rea.Recordset.Fields[0].get_value())+')';
   ins.Execute;
   if checkbox1.Checked then peop.Cells[4,peop.Row]:='Äà'
    else peop.Cells[4,peop.Row]:='Íåò';
   peop.Cells[5,peop.Row]:=wh.Text;
   peop.Cells[6,peop.Row]:=force.Text;
  end;
 cres.Filtered:=false;
 pm.Filtered:=false;
 toolbutton2click(form6)
end;

procedure TForm6.peopClick(Sender: TObject);
begin
 toolbutton2click(form6)
end;

procedure TForm6.peopKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 toolbutton2click(form6)
end;

procedure TForm6.ToolButton4Click(Sender: TObject);
begin
 edit1.Clear
end;
выходит сообщение1.JPG кидает сюда2.jpg
Дэдпул вне форума Ответить с цитированием
Старый 04.06.2017, 01:19   #3
Rockot
Форумчанин
 
Аватар для Rockot
 
Регистрация: 01.06.2012
Сообщений: 139
По умолчанию

Таким образом тебе никто не поможет, задай вопрос по факту, а не высылай код проекта. А то вот вам программа, вот ошибка я ничего не знаю, исправляйте. Так не пойдёт.
Следствие: 99% проблем, сваливаемых на Microsoft, является следствием тупости самих программистов.
Rockot вне форума Ответить с цитированием
Старый 04.06.2017, 13:55   #4
Sciv
Старожил
 
Аватар для Sciv
 
Регистрация: 16.05.2012
Сообщений: 3,211
По умолчанию

Чего Вы, уважаемый, в одних запросах используете параметры, а в других конкатенацию строк? С таким подходом неудивительно, что ошибки будут, выберите какой-то один способ, что-ли...

Код:
all.CommandText:='select * from who_when where wwrid='+quotedstr(cres.Recordset.Fields[0].get_value())+' and wwpid='+quotedstr(pm.Recordset.Fields[0].get_value());
Если у Вас айдишники, как им и положено быть, числового типа, то quotedstr тут совершенно лишние
Начал решать проблему с помощью регулярных выражений. Теперь решаю две проблемы...
Sciv вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Перенос проги из Паскаля в Delphi, ошибка 216 PhVG Помощь студентам 2 26.02.2013 14:32
Ошибка . MS SQL Server 2005 + Delphi maxflint БД в Delphi 0 17.04.2011 16:40
Delphi 10. Ошибка SQL. Egik_net БД в Delphi 2 05.03.2011 13:50
Ошибка при работе с Delphi 7 и SQL 2005 DimaP2010 БД в Delphi 1 28.12.2010 19:35
Ипорт из экселя в акссес Власов А.С. БД в Delphi 30 17.09.2009 12:51