Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Tablas planas (https://www.clubdelphi.com/foros/forumdisplay.php?f=20)
-   -   Tabla paradox no me valida registro duplicado (https://www.clubdelphi.com/foros/showthread.php?t=89056)

kcaARLOosz 18-09-2015 17:40:15

Tabla paradox no me valida registro duplicado
 
Utilizo una tabla paradox que creo en tiempo de ejecución...

Código:

TT_Temp.Close;
    tmp := c:\directorio\tabla\
    if not directoryexists(tmp) then
      mkdir(tmp);
    TT_Temp.DatabaseName := tmp;
    TT_Temp.TableName := 'NombreTablaTemp.DB';
    TT_Temp.TableType := ttParadox;
    with TT_Temp.FieldDefs do begin
      Clear;
      Add('NOPROV', ftInteger, 0, True);
      Add('TIPOMOV', ftString, 2, True);
      Add('FOLIO', ftInteger, 0, True);
    end;
    with TT_Temp.IndexDefs do begin
      Clear;
      Add('', 'NOPROV;TIPOMOV;FOLIO', [ixPrimary, ixUnique]);
    end;
    TT_Temp.CreateTable;
    TT_Temp.Open;

Mi problema es el siguiente:

Código:

if TT_Temp.State in [dsInsert,dsEdit]then begin
              TT_TempNOPROV.AsInteger:= 1;
              TT_TempTIPOMOV.AsString:='AC';
              TT_TempFOLIO.AsInteger:=1;
              TT_Temp.Post;
            end;

Supongamos que guardo el primer registro con los valores (1,'AC',1) y el segundo con (1,'AC',2), bien funciona. Pero si estoy editando el primer registro y le doy post sin modificar ningún valor, aunque la tabla esté en edición, me marca Key Violation, cosa que no me pasa cuando edito el segundo registro y le doy post sin modificar nada.


La franja horaria es GMT +2. Ahora son las 00:40:48.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi