PC Review


Reply
Thread Tools Rate Thread

Re: Raise Error NOT Catch('d)

 
 
William Ryan eMVP
Guest
Posts: n/a
 
      22nd May 2004
Tony, I think it may be an issue with the error severity. If I remember
correctly, SqlExceptions are only raised if they have a severity level > 10.
You can use the InfoMessage event of the SqlConnection to trap Infomessage
information http://www.knowdotnet.com/articles/connections.html

I know, for instance, if you use Print ' ' in T-SQL you can trap
those as well with infomessage adn I'm pretty sure that if you handle this
event you'll get the notification .

HTH,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
"Tony Goodridge via .NET 247" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
> I have a c# program that uses SQLDataAdapter.Fill to call a T-SQL stored

procedure, which should raise an error (when appropriate)..
>
> The Error is raised when run in QuerryAnalyser...
> "
>
> Server: Msg 50000, Level 16, State 1, Procedure usp_RetrievePSTHeader,

Line 39
> tblPSTHeader: No incompleted records for this Branch
> Stored Procedure: Pharmacy.dbo.usp_RetrievePSTHeader
> Return Code = 0"
>
> BUT there is a BLANK Line displayed, which appears to stop the c# program

trapping the exception....
>
> m_connection.Open();
> this.m_adaptor.Fill(pstHeaderDS.tblPSTHeader);
> }
> catch (SqlException e)
> {
> throw e; <---- never gets here
> }//end catch
> The Sp looks like this....
>
> SET NOCOUNT ON
> SELECT dbo.tblPSTHeader.PSTID ,
> dbo.tblPSTHeader.BranchID ,
> dbo.tblPSTHeader.PSTWeek ,
> dbo.tblPSTHeader.PSTDay ,
> dbo.tblPSTHeader.LastProductIndex ,
> dbo.tblPSTHeader.PSTDueDate ,
> isnull(dbo.tblPSTHeader.CountedBy,'') AS CountedBy,
> dbo.tblPSTHeader.PSTCompleteDate
> FROM dbo.tblPSTHeader INNER JOIN
> (SELECT MIN(PSTID) AS PSTID
> FROM dbo.tblPSTHeader
> WHERE (CountedBy IS NULL) AND (BranchID =

@BranchID)
> GROUP BY BranchID) v1
> ON dbo.tblPSTHeader.PSTID = v1.PSTID
> IF @@ROWCOUNT = 0
> BEGIN
> RAISERROR('tblPSTHeader: No incompleted records for this Branch',16,1)
> RETURN
> END
> END
> GO
>
>
> When I call the RAISERROR & RETURN before the SELECT (as a test!!) - the

exception is Caught O.K
>
> Could anyone please explain what I'm doing wrong please?
>
> --------------------------------
> From: Tony Goodridge
>
> -----------------------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
>
> <Id>XBwpiq6+JEKBIxQk8abaZQ==</Id>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
im trying to raise an invoice and it wont raise for me Edel Microsoft Access Getting Started 1 9th Feb 2009 01:51 PM
try..catch catch the error only running inside of VS.NET Dragos Hilbert Microsoft C# .NET 2 11th Mar 2008 04:35 PM
Form Err.Raise error not trapped by entry procedure error handler jchauvin@panix.com Microsoft Excel Programming 1 8th Feb 2006 11:19 AM
Raise Error?????? =?Utf-8?B?QWNjZXNzRGV2ZWxvcGVy?= Microsoft Access VBA Modules 4 29th Apr 2005 09:52 PM
err.raise inside catch? Coder Microsoft Dot NET Framework 4 13th Sep 2003 04:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:07 AM.