The problem that I'm experiencing is that in general the errors are detected
properly, but as soon as I try to use RAISERROR after checking any of the @@
variables (ie. @@ROWCOUNT, @@ERROR, @@FETCH_STATUS etc) the error is no
longer detected in VB.
Confusingly, if you run the sp from the query analyser the error is always
reported properly.
Stored proc code example...
**** EXAMPLE 1 ****
SELECT COUNT(Cmp_id) FROM Company WHERE Cmp_Account_No = @cmp_acc_no
IF @@ROWCOUNT <> 0
BEGIN
RAISERROR ('Account Number must be unique. Cannot Insert Company', 16, 1)
SELECT @new_cmp_id = -1
RETURN (99)
END
**** END ****
**** EXAMPLE 2 ****
DECLARE @RCount int
SELECT @RCount = COUNT(Cmp_id) FROM Company WHERE Cmp_Account_No =
@cmp_acc_no
IF @RCount <> 0
BEGIN
RAISERROR ('Account Number must be unique. Cannot Insert Company', 16, 1)
SELECT @new_cmp_id = -1
RETURN (99)
END
**** END ****
Example 1 fails to raise the error within VB and this issue must be worked
around by use of Example 2. Whilst this may seem a trivial example, (it is!)
I need to do some cursor work and check the @@FETCH_STATUS var which has
exactly the same effect, unfortunately it's not so easy to create a
workaround for.
Any help (even acknowlegement that I'm not alone) would be much
appreciated...
Cesare
Cesare <ces...@digitalmail.nospam.com> wrote in message
news:8bvogf$2kb8$1...@quince.news.easynet.net...
SP2 does fix many issues with RAISERROR most notably when using client side
cursors, unfortunately it hasn't helped me...
Cesare
chris petchey <ch...@2manykooks.freeserve.co.uk> wrote in message
news:uDjrqd0m$GA.246@cppssbbsa03...
--
Tibor Karaszi, Cornerstone Sweden AB
MCDBA, MCSE, MCSD, MCT, SQL Server MVP
Please reply to the newsgroup only, not by email.
Cesare <ces...@digitalmail.nospam.com> wrote in message
news:e972vH#n$GA.298@cppssbbsa05...