TMSStoredProc bug?

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 8
Joined: Mon 19 Sep 2005 09:42

TMSStoredProc bug?

Post by Frenk3 » Fri 30 Mar 2007 00:32

If I execute a procedure via TMSStoredProc and error on update is reported (Level16) TMSStoredProc doesn't generate exception. If I run the same procedure using Conn.CreateSQL::Execute, exception is generated properly. Any idea why?
Using D7, SDAC


Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Mon 02 Apr 2007 10:51

Your stored procedure 'sp_AddNarP' returns multiple result sets.
During execution of this stored procedure from your example an error occurs,
but after the first result set successfully generated and passed to the
client side.
The TMSStoredProc component receives the result set and doesn't request
subsequent results from server (as the user should process the first
received result set), that's why it knows nothing about the error. To get
next results of query execution you should use the TCustomMSDataSet.OpenNext
After the call of the TCustomMSDataSet.OpenNext method the TMSStoredProc
component will receive the information about the error occurred and generate
an exception.
When you call the TMSConnection.ExecSQL method, it uses internally created
TMSSQL component.
TMSSQL component doesn't request result sets, that's why it gets error
information immediately after execution and generates exception.
So, if you want your TMSStoredProc component to generate an exception, place
the following code after the call of the TMSStoredProc.Execute method:
while OpenNext do;

Post Reply