Ver Mensaje Individual
  #8  
Antiguo 28-03-2017
yuyidt yuyidt is offline
Miembro
NULL
 
Registrado: oct 2016
Posts: 40
Reputación: 0
yuyidt Va por buen camino
si me pueden ayudar con esto por favor

utilizo update para modificar registros pero me sigue apareciendo uno nuevo, ayuda por favor

Código Delphi [-]
procedure TForm5.BitBtn1Click(Sender: TObject);
var
  a:integer;
  begin
    with datamodule2.FDQuery6 do
    begin
      close;
      sql.Text:='SELECT ced_est FROM eva_estudiantes WHERE ced_est=:cedes';
      ParamByName('cedes').Value:='i';
      open;
      begin
        close;
        sql.Text:='INSERT INTO eva_maestro (nombre_examen,fecha_ini,fecha_fin,nota) VALUES (:nomex,:feini,:fefin,:not)';
        ParamByName('nomex').Value:=edit1.Text;
        ParamByName('feini').value:=formatdatetime('YYYY-MM-DD',DateTimePicker1.Date);
        ParamByName('fefin').value:=formatdatetime('YYYY-MM-DD',DateTimePicker2.Date);
        Parambyname('not').Value:=combobox2.Text;
        ExecSQL;
        close;
        sql.Text:='SELECT max(id_exa) as ultimo FROM eva_maestro';
        open;
        a:=FieldByName('ultimo').AsInteger;
        close;
        sql.Text:='INSERT INTO eva_detalle (id_exama,pregunta,tipo_pregunta,Opcion1,Opcion2,Opcion3,Opcion4,respuesta,puntos) SELECT '+
                      inttostr(a)+',pregunta,tipo_pregunta,Opcion1,Opcion2,Opcion3,Opcion4,respuesta,puntos FROM eva_estudiantes WHERE ced_est=:cedes';
        ParamByName('cedes').Value:='i';
        ExecSQL;
        close;
        sql.Text:='TRUNCATE eva_estudiantes';
        execsql;
        datamodule2.FDQuery5.close;
        datamodule2.FDQuery5.close;
        limpiar;
      end;
    end;
     begin
        with datamodule2.FDQuery3 do
       begin
       close;
        sql.Text:='SELECT * FROM eva_maestro WHERE id_exa=:idex';
       ParamByName('idex').value:=edit3.Text;
        open;

        if not isempty then
            begin
            sql.Text:='UPDATE eva_maestro SET id_exa=:idex,nombre_examen=:nomex,nota=:not,fecha_ini:fini,fecha_fin=:ffin';
            parambyname('idex').Value:=edit3.Text;
            ParamByName('nomex').Value:=edit1.Text;
            ParamByName('feini').value:=formatdatetime('YYYY-MM-DD',DateTimePicker1.Date);
            ParamByName('fefin').value:=formatdatetime('YYYY-MM-DD',DateTimePicker2.Date);
            Parambyname('not').Value:=combobox2.Text;
            ExecSQL;
            datamodule2.FDQuery3.Transaction.Commit;
            ExecSQL;
            Datamodule2.FDQuery3.Transaction.Commit;
            datamodule2.FDQuery3.SQL.Text:='select * from eva_maestro' ;
            end;
       end;
    end;
end;
Pero algo no esta bien porque me sigue creando un registro nuevo, no me modifica. Que le falta al código? o será que tengo algo que no debe ir?
Responder Con Cita