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>