Exception error message is incomplete

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
llober
Posts: 3
Joined: Wed 07 Nov 2007 21:40

Exception error message is incomplete

Post by llober » Wed 07 Nov 2007 21:52

Using SDAC 4.10.xx

The message in an Exception is incomplete. For example, if I execute this, where second INSERT will be a duplicate record :

INSERT INTO MyTable (KeyField, OtherField) values ('xxx', 'test1')
INSERT INTO MyTable (KeyField, OtherField) values ('xxx', 'test2')


I get this error in the exception message :

The statement has been terminated.

When the full and complete message is :

Violation of PRIMARY KEY constraint 'PK_MyTable'. Cannot insert duplicate key in object 'dbo.MyTable'.
The statement has been terminated.

This renders the messages virtually useless !

How can I get the correct ( and complete ) message in the exception message ?

Regards,
Lluis Ollé

yeohray
Posts: 56
Joined: Mon 26 Mar 2007 01:25

Post by yeohray » Thu 08 Nov 2007 01:04

Strange, but I could not reproduce the error. I did the following:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
  f: Integer;
begin
  msquery1.SQL.Text := 'insert into test301 values (1, 1)  insert into test301 values (1, 1)';

  try
    msquery1.Execute;
  except
    on E: Exception do
    begin
      Log(E.Message);
    end;
  end;
end;
The error message raised was

Code: Select all

The statement has been terminated.
Violation of PRIMARY KEY constraint 'PK__test301__5AEE82B9'. Cannot insert duplicate key in object 'test301'.
The only anomaly was that the order of the messages was reversed. I am using Delphi 7 with SDAC 4.10.0.10.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 09 Nov 2007 10:08

llober wrote:The message in an Exception is incomplete. For example, if I execute this, where second INSERT will be a duplicate record :

INSERT INTO MyTable (KeyField, OtherField) values ('xxx', 'test1')
INSERT INTO MyTable (KeyField, OtherField) values ('xxx', 'test2')


I get this error in the exception message :

The statement has been terminated.

When the full and complete message is :

Violation of PRIMARY KEY constraint 'PK_MyTable'. Cannot insert duplicate key in object 'dbo.MyTable'.
The statement has been terminated.
Try to download the last SDAC build (4.30.0.12), and check whether the problem is reproduced with it.
If the problem is still persists, send me please a complete small sample at sdac*crlab*com to demonstrate it, including script to create and fill table.
Also supply me the following information:
- exact version of your IDE;
- exact version of SQL Server and client. You can see it in the Info sheet of TMSConnection Editor.

llober
Posts: 3
Joined: Wed 07 Nov 2007 21:40

Solved

Post by llober » Mon 12 Nov 2007 21:45

SDAC is working ok ... it was a problem with th eapplication.

Thanks
LLuis Olle

Post Reply