DataSet.Post não está salvando no banco
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
Curtidas 0
Respostas
Alessandro Yamasaki
24/03/2017
Já tentou usar o DSINSERIR.DataSet.ApplyUpdates logo apos o DSINSERIR.DataSet.POST;
GOSTEI 0