Hello i made a test with bufferdata table to validate or work with event on duplicate index key or record duplicate record of index fields definition but don't me add records always show a error...
procedure TFormCtrlInv.FormShow(Sender: TObject);
begin
BDInvFis.FieldDefs.Clear;
BDInvFis.FieldDefs.Add('Rowid',ftInteger,6);
BDInvFis.FieldDefs.Add('NumProd',ftString,20);
BDInvFis.FieldDefs.Add('NomProd',ftString,120);
BDInvFis.FieldDefs.Add('Fecha',ftDate,0);
BDInvFis.FieldDefs.Add('Catidad',ftFloat,10);
BDInvFis.FieldDefs.Add('Afectado',ftBoolean,0);
BDInvFis.FieldDefs.Add('ContadoPor',ftString,20);
BDInvFis.FieldDefs.Add('Almacen',ftString,6);
BDInvFis.FieldDefs.Add('eXISTENCIA',ftfLOAT,10);
BDInvFis.CreateDataset;
BDInvFis.IndexDefs.Add('Prodindex','numprod',[ixUnique,ixCaseInsensitive]);
if( BDInvFis.Active = false) then begin
BDInvFis.open;
end;
to here look everthing is ok table is created and open..
here i add a empty record
procedure TFormCtrlInv.BtnAddClick(Sender: TObject);
begin
BDinvFis.Append;
BDInvFis.FieldByName('RowId').AsInteger:=bDInvFis.RecordCount+1;
DbGInvfis.SetFocus;
EBprod.Text:=bDInvFis.FieldByName('NumProd').AsString ;
DbGInvfis.SelectedIndex:=0;
end;
and when i assing value to record..
procedure TFormCtrlInv.EBProdExit(Sender: TObject);
var Tsql:TsqlQuery;
// RowId:Integer;
begin
Tsql:= TsqlQuery.Create(nil);
Tsql.Database:= DM.MySQLCOpti;
Tsql.Transaction:= DM.SQLTopti;
Counted:=false;
if( EBprod.Text<>'') Then begin
BDInvFis.edit;
BDInvFis.FieldByName('NumProd').AsString := EBProd.Text;
BDInvFis.Post;
end;
just on post send this error, if not index active i can edit values but when index id open...