Recent

Author Topic: BufferData not let append records when index is active  (Read 845 times)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 443
BufferData not let append records when index is active
« on: May 29, 2023, 07:28:55 pm »
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...

Code: Pascal  [Select][+][-]
  1. procedure TFormCtrlInv.FormShow(Sender: TObject);
  2. begin
  3.   BDInvFis.FieldDefs.Clear;
  4.   BDInvFis.FieldDefs.Add('Rowid',ftInteger,6);
  5.   BDInvFis.FieldDefs.Add('NumProd',ftString,20);
  6.   BDInvFis.FieldDefs.Add('NomProd',ftString,120);
  7.   BDInvFis.FieldDefs.Add('Fecha',ftDate,0);
  8.   BDInvFis.FieldDefs.Add('Catidad',ftFloat,10);
  9.   BDInvFis.FieldDefs.Add('Afectado',ftBoolean,0);
  10.   BDInvFis.FieldDefs.Add('ContadoPor',ftString,20);
  11.   BDInvFis.FieldDefs.Add('Almacen',ftString,6);
  12.   BDInvFis.FieldDefs.Add('eXISTENCIA',ftfLOAT,10);
  13.   BDInvFis.CreateDataset;
  14.   BDInvFis.IndexDefs.Add('Prodindex','numprod',[ixUnique,ixCaseInsensitive]);
  15.  
  16.   if( BDInvFis.Active = false) then begin
  17.      BDInvFis.open;
  18.  
  19.   end;
  20.  
to here look everthing is ok table is created and open..
here i add a empty record
Code: Pascal  [Select][+][-]
  1. procedure TFormCtrlInv.BtnAddClick(Sender: TObject);
  2. begin
  3.    BDinvFis.Append;
  4.    BDInvFis.FieldByName('RowId').AsInteger:=bDInvFis.RecordCount+1;
  5.    DbGInvfis.SetFocus;
  6.    EBprod.Text:=bDInvFis.FieldByName('NumProd').AsString ;
  7.    DbGInvfis.SelectedIndex:=0;
  8.  
  9. end;
  10.  
  11.  
and when i assing value to record..
Code: Pascal  [Select][+][-]
  1. procedure TFormCtrlInv.EBProdExit(Sender: TObject);
  2. var Tsql:TsqlQuery;
  3. //    RowId:Integer;
  4. begin
  5.   Tsql:= TsqlQuery.Create(nil);
  6.   Tsql.Database:= DM.MySQLCOpti;
  7.   Tsql.Transaction:= DM.SQLTopti;
  8.   Counted:=false;
  9.   if( EBprod.Text<>'') Then begin
  10.        BDInvFis.edit;
  11.        BDInvFis.FieldByName('NumProd').AsString := EBProd.Text;
  12.        BDInvFis.Post;
  13.  end;
  14.  
  just on post send this error, if not index active i can edit values but when index id open...


paweld

  • Hero Member
  • *****
  • Posts: 966
Re: BufferData not let append records when index is active
« Reply #1 on: May 30, 2023, 05:18:39 pm »
prepare some simple program that shows this error, because the component itself is ok.
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018