Fórum DataSet.Post não está salvando no banco #579342
24/03/2017
0
Bom dia estou utilizando o seguinte codigo para inserir no meu banco porém o codigo está executando mas não grava no banco de dados!
qSqlInsere.Active := false;
qSqlInsere.sql.text := 'select * from '+tabela2.text;
qSqlInsere.Active := true;
wpaciente := FDQUERY1.FieldByName('paciente').Value;
wdata := FDQUERY1.FieldByName('data').Value;
wid := FDQUERY1.FieldByName('id').Value;
while (FDQUERY1.Eof = FALSE) do begin
if ((wpaciente = FDQUERY1.FieldByName('paciente').Value) and (wdata = FDQUERY1.FieldByName('data').Value)) then begin
wpaciente := FDQUERY1.FieldByName('paciente').Value;
wdata := FDQUERY1.FieldByName('data').Value;
wid := FDQUERY1.FieldByName('id').Value;
end
else begin
// Gravar Registro no bd
fdbusca.Active := false;
fdbusca.sql.text := 'select id,paciente,data,texto,revisao from '+tabela1.text+' where id='+inttostr(wid);
fdbusca.Active := true;
qSqlInsere.Active := false;
qSqlInsere.sql.text := 'select * from '+tabela2.text+' where id=1';
qSqlInsere.Active := true;
DSINSERIR.DataSet.Insert;
DSINSERIR.DataSet.FieldByName('CODCLI').Value := fdbusca.FieldByName('paciente').Value;
DSINSERIR.DataSet.FieldByName('DATAREGISTRO').Value:= fdbusca.FieldByName('data').Value;;
DSINSERIR.DataSet.FieldByName('ANOTACAO').Value := fdbusca.FieldByName('texto').Value;;
DSINSERIR.DataSet.FieldByName('REVISAO').Value := fdbusca.FieldByName('revisao').Value;
DSINSERIR.DataSet.Post;
wpaciente := FDQUERY1.FieldByName('paciente').Value;
wdata := FDQUERY1.FieldByName('data').Value;
wid := FDQUERY1.FieldByName('id').Value;
end;
try
fdquery1.Next;
Application.ProcessMessages;
except
on E: Exception do
fdquery1.Next;
end;
end;
Application.ProcessMessages;
FDQUERY2.CLOSE;
FDQUERY2.SQL.Text := 'SELECT * FROM '+tabela2.Text;
FDQUERY2.OPEN;
showmessage('Processo concluído.'+DateToStr(now()))
end;Rodrigo Oliveira
Curtir tópico
+ 0
Responder
Post mais votado
24/03/2017
Use
ApplyUpdates;
CommitUpdates;
ApplyUpdates;
CommitUpdates;
Alessandro Yamasaki
Responder
Gostei + 1
Mais Posts
24/03/2017
Gutierry Pereira
Boa tarde, verifique se a FDQUERY1 esta com cached update = true, se sim nesses casos para percistir no banco deve se utilizar o applyupdate..
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)