Insert does not return an error 
Author Message
 Insert does not return an error

I apologize for posting this a second time.  I posted this the first
time from
work and I just got my provider to add this group to their server and my
first
message isn't loaded on their server.  Also, I forgot to put my e-mail
address
at the bottom of the first posting

I'm using a TQuery to insert records into a Paradox table.  I want to
trap for an error when I insert a record which would cause a duplicate
key.  When I manually add a record using the database desktop, I get a
key violation message.

My application just doesn't insert the record.  I'm in a try ...except
block and but I never enter the except block.  Has anyone else had
this problem?

In the sample code below, SrdID is the key to my SrcFiles table.

  with TestQuery do
    try
      Close;
      Sql.Clear;
      Sql.Add('insert into SrcFiles ' +
        '(SrcID, SrcName) Values(:SrcId, :SrcName)');
      Params[0].AsInteger := 12;
      Params[1].AsString := 'FILE1.TXT';

      try
        ExecSQL;
      except
        MessageDlg('There was an error.', mtError, [mbOK], 0);
        { Here I would trap for the error when I tried to insert a
          record with a duplicate key. }
      end;
    finally
      Close;
    end;




Thu, 24 Sep 1998 04:00:00 GMT  
 Insert does not return an error
I apologize for posting this a second time.  I posted this the first
time from
work and I just got my provider to add this group to their server and my
first
message isn't loaded on their server.  Also, I forgot to put my e-mail
address
at the bottom of the first posting

I'm using a TQuery to insert records into a Paradox table.  I want to
trap for an error when I insert a record which would cause a duplicate
key.  When I manually add a record using the database desktop, I get a
key violation message.

My application just doesn't insert the record.  I'm in a try ...except
block and but I never enter the except block.  Has anyone else had
this problem?

In the sample code below, SrdID is the key to my SrcFiles table.

  with TestQuery do
    try
      Close;
      Sql.Clear;
      Sql.Add('insert into SrcFiles ' +
        '(SrcID, SrcName) Values(:SrcId, :SrcName)');
      Params[0].AsInteger := 12;
      Params[1].AsString := 'FILE1.TXT';

      try
        ExecSQL;
      except
        MessageDlg('There was an error.', mtError, [mbOK], 0);
        { Here I would trap for the error when I tried to insert a
          record with a duplicate key. }
      end;
    finally
      Close;
    end;




Thu, 24 Sep 1998 04:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ExecSQL of Insert is not returning an error

2. EOutOfResources Error (Unable to insert a line) doing a TQuery

3. Error: ...not in Edit or Insert mode!

4. HELP : "Invalid Paramater", when doing Tquery.Open, seems to not release resources

5. Delphi *.hlp files still not done

6. Month number being returned not correct

7. Function not returning record

8. Stored proc not returning values with output parameters

9. Key Violations Not Returned by BDE / Paradox in Delphi 2

10. Fw: Key Violations Not Returned by BDE / Paradox in Delphi 2

11. Key Violations Not Returned by BDE / Paradox in Delphi 2

12. Error Trapping - How Is It Done?

 

 
Powered by phpBB® Forum Software