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

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

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

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

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

Ответ
 
Опции темы Поиск в этой теме
Старый 31.05.2017, 16:37   #21
Serge_Bliznykov
Старожил
 
Регистрация: 09.01.2008
Сообщений: 26,238
По умолчанию

Цитата:
Сообщение от Дэдпул Посмотреть сообщение
все верно ?
нет, не совсем.

во-первых, Вы мой кусок кода почему-то вставили криво (выкинули из него часть, которая нужна).

во-вторых, про вставку в insert into resolution уже Аватар написал замечание.
Serge_Bliznykov вне форума Ответить с цитированием
Старый 31.05.2017, 16:51   #22
Дэдпул
Пользователь
 
Регистрация: 28.04.2016
Сообщений: 34
По умолчанию

Цитата:
Сообщение от Serge_Bliznykov Посмотреть сообщение
нет, не совсем.

во-первых, Вы мой кусок кода почему-то вставили криво (выкинули из него часть, которая нужна).

во-вторых, про вставку в insert into resolution уже Аватар написал замечание.
Все по инструкции ведь
Код:
ads.Active:=false;
 ads.CommandText:='select * from res_givers, organs where res_givers.rgfname='+quotedstr(rgfname.Text)+' and res_givers.rgnoname='+quotedstr(rgnoname.Text)+' and res_givers.rgorg=organs.oid and organs.oname='+quotedstr(orgname.Text);
 ads.Active:=true;
 if ads.RecordCount=0 then
  begin
   ads.Active:=false;
   ads.CommandText:='select * from organs where organs.oname='+quotedstr(orgname.Text);
   ads.Active:=true;
   if ads.RecordCount>0 then begin
      adc.CommandText:='insert into res_givers (rgorg, rgfname, rgnoname) values('+
          ads.FieldByName('oid').AsString+', '+quotedstr(rgfname.Text)+', '+quotedstr(rgnoname.Text)+')';
      adc.Execute
   end
   else begin
      ShowMessage('Ошибка. В БД нет организации (суда)  '+orgname.Text);
      Exit
   end;
  end;
Дэдпул вне форума Ответить с цитированием
Старый 31.05.2017, 17:08   #23
Serge_Bliznykov
Старожил
 
Регистрация: 09.01.2008
Сообщений: 26,238
По умолчанию

Цитата:
Сообщение от Дэдпул Посмотреть сообщение
Все по инструкции ведь
ок. покажите мне в вашем коде вот эти строчки:

Код:
ads.Active:=false;
 ads.CommandText:='select * from res_givers, organs where res_givers.rgfname='+quotedstr(rgfname.Text)+' and res_givers.rgnoname='+quotedstr(rgnoname.Text)+' and res_givers.rgorg=organs.oid and organs.oname='+quotedstr(orgname.Text);
 ads.Active:=true;
 if ads.RecordCount=0 then
  begin
....
Serge_Bliznykov вне форума Ответить с цитированием
Старый 31.05.2017, 17:35   #24
Дэдпул
Пользователь
 
Регистрация: 28.04.2016
Сообщений: 34
По умолчанию

Цитата:
Сообщение от Serge_Bliznykov Посмотреть сообщение
ок. покажите мне в вашем коде вот эти строчки:
вот же
Изображения
Тип файла: jpg Снимок.jpg (47.2 Кб, 114 просмотров)
Дэдпул вне форума Ответить с цитированием
Старый 31.05.2017, 17:42   #25
Serge_Bliznykov
Старожил
 
Регистрация: 09.01.2008
Сообщений: 26,238
По умолчанию

Цитата:
Сообщение от Дэдпул Посмотреть сообщение
вот же
всё, теперь вижу.

ну так проблема решена, код работает?
Serge_Bliznykov вне форума Ответить с цитированием
Старый 31.05.2017, 17:46   #26
Дэдпул
Пользователь
 
Регистрация: 28.04.2016
Сообщений: 34
По умолчанию

Цитата:
Сообщение от Дэдпул Посмотреть сообщение
Код:

ads.Active:=false;
ads.CommandText:='select * from organs where organs.oname='+quotedstr(orgname.Te xt);
ads.Active:=true;
if ads.RecordCount>0 then begin
adc.CommandText:='insert into res_givers (rgorg, rgfname, rgnoname) values('+
ads.FieldByName('oid').AsString+', '+quotedstr(rgfname.Text)+', '+quotedstr(rgnoname.Text)+')';
adc.Execute
end
else begin
ShowMessage('Ошибка. В БД нет организации (суда) '+orgname.Text);
Exit
end;
end;
peopds.Active:=false;
peopds.Filtered:=false;
peopds.CommandText:='select * from resolution where rregnum='+quotedstr(regnum.Text)+' and rregdate>=ate';
peopds.Parameters.ParamByName('date ').DataType := ftDate;
peopds.Parameters.ParamByName('date ').Value := regdate.Date;
peopds.Active:=true;
if peopds.RecordCount=0 then
begin
ads.Active:=false;
ads.CommandText:='select * from res_givers, organs where res_givers.rgfname='+quotedstr(rgfn ame.Text)+' and res_givers.rgnoname='+quotedstr(rgn oname.Text)+' and res_givers.rgorg=organs.oid and organs.oname='+quotedstr(orgname.Te xt);
ads.Active:=true;
adc.CommandText:='insert into resolution (rrgid,rart,rregnum,rregdate,rdate, rtodate,rtotime,rprice) values(0, ' + quotedstr(ads.Recordset.Fields[0].get_value())+', '+quotedstr(art.Text)+', '+quotedstr(regnum.Text)+', ate1, ate2, ate3, :time, ' + quotedstr(floattostr(0))+')';
adc.Parameters.ParamByName('date1') .DataType := ftDate;
adc.Parameters.ParamByName('date1') .Value := regdate.Date;
adc.Parameters.ParamByName('date2') .DataType := ftDate;
adc.Parameters.ParamByName('date2') .Value := date.Date;
adc.Parameters.ParamByName('date3') .DataType := ftDate;
adc.Parameters.ParamByName('date3') .Value := todate.Date;
adc.Parameters.ParamByName('time'). DataType := ftTime;
adc.Parameters.ParamByName('time'). Value := totime.Time;
adc.Execute
end;
for i:=1 to peoples.count do
begin
rgds.Active:=false;
rgds.CommandText:='select * from cities where cname='+quotedstr(peoples.p[i].city);
rgds.Active:=true;
if rgds.RecordCount=0 then
begin
adc.CommandText:='insert into cities (cname) values('+quotedstr(peoples.p[i].city)+')';
adc.Execute;
rgds.Active:=false;
rgds.Active:=true
end;
ads.active:=false;
ads.CommandText:='select * from peoples where pfname='+quotedstr(peoples.p[i].fname)+' and pnname='+quotedstr(peoples.p[i].nname)+' and poname='+quotedstr(peoples.p[i].oname)+' and pwasborn='+inttostr(peoples.p[i].ywb);
ads.active:=true;
if ads.RecordCount=0 then
begin
adc.CommandText:='insert into peoples (pfname,pnname,poname,pwasborn,pcid ,padr) values('+quotedstr(peoples.p[i].fname)+', '+quotedstr(peoples.p[i].nname)+', '+quotedstr(peoples.p[i].oname)+', '+inttostr(peoples.p[i].ywb)+', '+quotedstr(rgds.Recordset.Fields[0].get_value())+', '+quotedstr(peoples.p[i].adress)+')';
adc.Execute;
ads.Active:=false;
ads.Active:=true
end;
kind.Filter:='sname='+quotedstr(peo ples.p[i].stat);
kind.Filtered:=true;
if kind.RecordCount=0 then
begin
adc.CommandText:='insert into stat (sname) values('+quotedstr(peoples.p[i].stat)+')';
adc.Execute;
kind.Active:=false;
kind.Active:=true
end;
peopds.Active:=false;
peopds.Active:=true;
adc.CommandText:='insert into who_why (wwrid,wwpid,wwsid) values('+quotedstr(peopds.Recordset .Fields[0].get_value())+', '+quotedstr(ads.Recordset.Fields[0].get_value())+', '+quotedstr(kind.Recordset.Fields[0].get_value())+')';
adc.Execute;
kind.Filtered:=false
end;
form1.Close
end;

procedure TForm1.rgfnameChange(Sender: TObject);
begin
rgds.Filter:='rgfname='+quotedstr(r gfname.Text);
rgds.Filtered:=true;
if rgds.RecordCount=1 then rgnoname.Text:=rgds.Recordset.Field s[1].get_value();
rgds.Filtered:=false
end;

end.
а вот с этими как быть?
Дэдпул вне форума Ответить с цитированием
Старый 31.05.2017, 17:53   #27
Дэдпул
Пользователь
 
Регистрация: 28.04.2016
Сообщений: 34
По умолчанию

Код:
 adc.CommandText:='insert into resolution (rrgid,rart,rregnum,rregdate,rdate, rtodate,rtotime,rprice) values(0, ' + quotedstr(ads.Recordset.Fields[0].get_value())+', '+quotedstr(art.Text)+', '+quotedstr(regnum.Text)+', :date1, :date2, :date3, :time, ' + quotedstr(floattostr(0))+')';
вот эта строчка .(0,'... Это она передает коду Resolution 0? А как сним быть?
Дэдпул вне форума Ответить с цитированием
Старый 31.05.2017, 18:39   #28
Дэдпул
Пользователь
 
Регистрация: 28.04.2016
Сообщений: 34
По умолчанию

С нулями в прошлом.Теперь все по порядку выводит.Но ошибку не перестает выдавать.перенаправляет на adc.CommandText:='insert into who_why (w
Изображения
Тип файла: jpg Снимок.JPG (93.5 Кб, 108 просмотров)
Тип файла: jpg уув.JPG (34.0 Кб, 111 просмотров)
Тип файла: jpg выводит.JPG (86.1 Кб, 108 просмотров)
Дэдпул вне форума Ответить с цитированием
Старый 01.06.2017, 14:29   #29
Дэдпул
Пользователь
 
Регистрация: 28.04.2016
Сообщений: 34
По умолчанию

Цитата:
Сообщение от Serge_Bliznykov Посмотреть сообщение
ну так проблема решена, код работает?
Здравствуйте.Все решил до 5 формы .Но на 5 форме опять проблемка есть.Программа не видит записи в бд
Код:
procedure tform5.getinfo;
var str:string; i,j,q:integer;
begin
{ cr.CommandText:='drop table tmp';
 cr.Execute;
 cr.CommandText:='create table tmp (num int not null, t datetime not null, org varchar(30) not null, rg varchar(30) not null, col int not null, ex varchar(100) not null)';
 cr.Execute;}
 post.Active:=false;
 post.Filtered:=false;
 str:='';
 str:=datetostr(curdat.date);
 post.CommandText:='select resolution.rid, resolution.rregnum, resolution.rtotime, organs.oname, res_givers.rgfname from resolution, organs, res_givers where resolution.rtodate=:date'+
                   ' and resolution.rrgid=res_givers.rgid and res_givers.rgorg=organs.oid order by rtotime';
 post.Parameters.ParamByName('date').DataType := ftDate;
 post.Parameters.ParamByName('date').Value := curdat.date;
 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;

procedure TForm5.FormShow(Sender: TObject);
var t:systemtime; str:string; i:integer;
begin
 adt.Active:=false;
 adt.filtered:=false;
 adt.Active:=true;
 bdol.Clear;
 for i:=1 to adt.RecordCount do
  begin
   bdol.Items.Add(adt.Recordset.Fields[1].get_value());
   adt.Next
  end;
 bfname.Clear;
 bnname.Clear;
 boname.Clear;
 sol.Active:=false;
 sol.filtered:=false;
 sol.CommandText:='select * from soldiers';
 sol.Active:=true;
 for i:=1 to sol.RecordCount do
  begin
   bfname.Items.Add(sol.Recordset.Fields[1].get_value());
   sol.Next
  end;
 getsystemtime(t);
 str:='';
 str:=inttostr(t.wDay)+'.'+inttostr(t.wMonth)+'.'+inttostr(t.wYear);
 curdat.Date:=strtodate(str);
 getinfo
end;

procedure TForm5.curdatChange(Sender: TObject);
begin
 getinfo
end;

procedure TForm5.bfnameChange(Sender: TObject);
var i:integer;
begin
 bdol.Text:='';
 bnname.Clear;
 boname.Clear;
 sol.Filtered:=false;
 sol.Filter:='sfname='+quotedstr(bfname.Text);
 sol.Filtered:=true;
 if sol.RecordCount=1 then
  begin
   bnname.Text:=sol.Recordset.Fields[2].get_value();
   boname.Text:=sol.Recordset.Fields[3].get_value()
  end;
 for i:=1 to sol.RecordCount do
  begin
   bnname.Items.Add(sol.Recordset.Fields[2].get_value());
   sol.Next
  end;
 sol.Filtered:=false
end;

procedure TForm5.bnnameChange(Sender: TObject);
begin
 boname.Clear;
 bdol.Text:='';
 sol.Filtered:=false;
 sol.Filter:='sfname='+quotedstr(bfname.Text)+' and snname='+quotedstr(bnname.Text);
 sol.Filtered:=true;
 if sol.RecordCount=1 then boname.Text:=sol.Recordset.Fields[3].get_value();
 sol.Filtered:=false
end;

procedure TForm5.ToolButton1Click(Sender: TObject);
begin
 if bfname.Text='' then
  begin
   messagedlg('Íå âñå ïîëÿ çàïîëíåíû. Ñîõðàíåíèå íåâîçìîæíî.',mterror,[mbok],0);
   exit
  end;
 if bnname.Text='' then
  begin
   messagedlg('Íå âñå ïîëÿ çàïîëíåíû. Ñîõðàíåíèå íåâîçìîæíî.',mterror,[mbok],0);
   exit
  end;
 if boname.Text='' then
  begin
   messagedlg('Íå âñå ïîëÿ çàïîëíåíû. Ñîõðàíåíèå íåâîçìîæíî.',mterror,[mbok],0);
   exit
  end;
 if bdol.Text='' then
  begin
   messagedlg('Íå âñå ïîëÿ çàïîëíåíû. Ñîõðàíåíèå íåâîçìîæíî.',mterror,[mbok],0);
   exit
  end;

 post.Filtered:=false;
 post.Filter:='rregnum='+quotedstr(data.Cells[0,data.Row]);
 post.Filtered:=true;
 adt.Filtered:=false;
 adt.Filter:='dtype='+quotedstr(bdol.Text);
 adt.Filtered:=true;
 if adt.RecordCount=0 then
  begin
   cr.CommandText:='insert into dol (dtype) values('+quotedstr(bdol.Text)+')';
   cr.Execute;
   adt.Active:=false;
   adt.Active:=true;
  end;
 sol.Filtered:=true;
 if sol.RecordCount=0 then
  begin
   cr.CommandText:='insert into soldiers (sfname,snname,soname) values('+quotedstr(bfname.Text)+', '+quotedstr(bnname.Text)+', '+quotedstr(boname.Text)+')';
   cr.Execute;
   sol.Active:=false;
   sol.Active:=true
  end;
 bludi.Active:=false;
 bludi.Filtered:=false;
 bludi.CommandText:='select * from who_whom_why where wwwsid='+quotedstr(sol.Recordset.Fields[0].get_value())+' and wwwdid='+quotedstr(adt.Recordset.Fields[0].get_value())+' and wwwrid='+quotedstr(post.Recordset.Fields[0].get_value());
 bludi.Active:=true;
 if bludi.RecordCount=0 then
  begin

  end;
 data.Cells[5,data.Row]:=data.Cells[5,data.Row]+bfname.Text+' ';
 bfname.Text:='';
 bnname.Clear;
 boname.Clear;
 bdol.Text:=''
end;

procedure TForm5.ToolButton2Click(Sender: TObject);
begin
 bfname.Text:='';
 bnname.Clear;
 boname.Clear;
 bdol.Text:=''
end;

procedure TForm5.ToolButton3Click(Sender: TObject);
begin
 post.Filtered:=false;
 post.Filter:='rregnum='+quotedstr(data.Cells[0,data.Row]);
 post.Filtered:=true;
 cr.CommandText:='delete from who_whom_why where wwwrid='+quotedstr(post.Recordset.Fields[0].get_value());
 cr.Execute;
 data.Cells[5,data.Row]:='';
 bfname.Text:='';
 bnname.Clear;
 boname.Clear;
 bdol.Text:=''
end;
Код:
 post.CommandText:='select resolution.rid, resolution.rregnum, resolution.rtotime, organs.oname, res_givers.rgfname from resolution, organs, res_givers where resolution.rtodate=:date'+
                   ' and resolution.rrgid=res_givers.rgid and res_givers.rgorg=organs.oid order by rtotime';
 post.Parameters.ParamByName('date').DataType := ftDate;
 post.Parameters.ParamByName('date').Value := curdat.date;
и мне кажется что ошибочка вот тут.Нужен совет Эксперта
Изображения
Тип файла: jpg 1.JPG (49.8 Кб, 148 просмотров)
Дэдпул вне форума Ответить с цитированием
Старый 01.06.2017, 16:02   #30
Sciv
Старожил
 
Аватар для Sciv
 
Регистрация: 16.05.2012
Сообщений: 3,211
По умолчанию

Попробуйте из запроса убрать весь блок WHERE и проверьте.
Начал решать проблему с помощью регулярных выражений. Теперь решаю две проблемы...
Sciv вне форума Ответить с цитированием
Ответ


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

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

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


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
перенос базы данных на sql server ce ts-alan C/C++ Базы данных 1 27.03.2014 20:50
Перенос базы данных. (Microsoft SQL Server 2005) Gleg БД в Delphi 8 15.01.2013 21:29
Преобразование базы данных Access в формат SQL Server Alar Microsoft Office Access 5 18.04.2010 01:46
перенос данных из Access в MS SQL Server2000 ГОСЕАН БД в Delphi 5 28.12.2007 12:31