"Patrick" <(E-Mail Removed)> wrote in message
news:1B7FF39F-7ECE-4B70-84B3-(E-Mail Removed)...
> Using Microsoft.Practices.EnterpriseLibrary.Data, how do I capture the
> return
> value from executing a stored procedure on SQL Server 2000 (i.e., how
> could
> I tell the Stored Procedure did not return 0 [indicating failure] or that
> a
> transaction the stored procedure begun had been rolled back):
>
> No exceptions were thrown from the following when -1 was returned and
> transaction rolled back:
> Database db = DatabaseFactory.CreateDatabase();
>
> string sqlCommand = "uspCreator";
> DBCommandWrapper creatorCommandWrapper =
> db.GetStoredProcCommandWrapper(sqlCommand);
>
> db.ExecuteNonQuery(creatorCommandWrapper);
Checking the return code of stored procedures is for server side invocation,
and is simply a workaround for the fact that when a stored procedure calls
another stored procedure, it cannot capture the error message. Client code
should detect failure from the error message.
So the stored procedure should indicate failure with both a return code, and
an error message. If no error message is currently being generated on
failure, then you should generate one using RAISERROR in the stored
procedure.
David
|