EDBEngineError - Key Violation Help!!! 
Author Message
 EDBEngineError - Key Violation Help!!!

I am having a problem with a key violation error. I have a try..except
handling
around the post. This displays a message in a debug box, but the
application
still displays the key violation message and does not continue importing.
I
don't want to user to see such a cryptic message. I have been reading
magazines, books and Newsgroup messages trying to find the solution to the
problem. If you have any suggestions I am open to any. The below snipit of
code is a variation of what I am using.

Thanks in advance for your help.

procedure TImportDlg.ImportBtnClick(Sender: TObject);
var OFile       : TextFile;
     RecCount   : Integer;
     tmpStr30   : string[30];
     tmpstr60   : string[60];
     tmpstr32   : string[32];

begin

  if Edit1.Text = '' then
  begin
    MessageDlg('File Name must be selected using the browser',
                        mtInformation, [mbOK], 0);
    exit;
  end;
  RecCount := 0;
  t1.Open;
  t1.First;
  AssignFile(OFile, OpenImportDialog.FileName); { File selected in dialog

Quote:
}

  Reset(OFile);
  MainForm.DebugBox1.add('Start of Import');
  while not eof(OFile) do
  begin
    t1.insert;
    Read(OFile, tmpstr30);
    t1CobolName.AsString := tmpstr30;
    Read(Ofile, tmpstr60);
    t1BusNameFull.AsString := tmpstr60;
    Read(Ofile, tmpstr32);
    t1BusNameShrt.AsString := tmpstr32;
    RecCount := RecCount + 1;
    t1DescrNbr.value := RecCount;
    t1Deleted.Value := False;
    t1CompleteDesc.Value := True;
    t1LstUpdtTS.Value := NOW;
    t1LstUpdtUser.AsString := 'IMPORTED';
    readln(OFile);
    try
         t1.Post
    except on E: EDBEngineError do
      Begin
       MainForm.DebugBox1.add(tmpstr30 + '  Record #: ' +
           IntToStr(RecCount) + ' Exception Occurred Insert this record');
       ShowError(E);
      End;
    end;
  end;
  MainForm.DebugBox1.add('End of import');
  CloseFile(OFile);
  t1.Close;
  BlinkLabel1.Caption := 'Completed...';
  BlinkLabel1.Font.Color := clBlue;
  BlinkLabel1.visible := true;
  ImportBtn.Enabled := False;
  BrowserBtn.Enabled := False;
end;


Sat, 21 Mar 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Preventing Key Violation for duplicate keys

2. Paradox Key Violation - changing a keyed field

3. Paradox Autoincrement Fields Cause Key Violation -- Help!

4. Help..Traping key violations in a database

5. Help: Paradox and Key Violations

6. DATABASE KEY VIOLATION ERROR - HELP !

7. PLEASE HELP! SQL Insert key violation error

8. Key violation-Need help emergency

9. Help: Key Violation errors

10. EdbEngineError - Record/Key deleted

11. D2: EDBEngineError: 'Record/key deleted'

12. EDBEngineError..."Record/Key deleted"

 

 
Powered by phpBB® Forum Software