473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

PRINT messages inapproriately ending up in SqlException's message property

Occasionally my users will try to perform an action and be presented with an
exception raised directly from SQL Server, in example:

SET @err = 'a user-friendly error condition message'
RAISERROR(@err, 16, 1, 1)
RETURN

The exception type thrown is a System.Data.SqlClient.SqlException, and its
message property holds the exception text. Works well for the most part.
However, a lot of times the SQL error conditions happen after a trigger is
fired, and I tend to place informational PRINT statements in my triggers so
I know what they are doing and when. So to give a simplified example to
reproduce this condition...

PRINT 'some non-user-friendly information...'
PRINT 'more non-user-friendly information...'
SET @err = 'a user-friendly error condition message'
RAISERROR(@err, 16, 1, 1)
RETURN

Now the message property in the corresponding
System.Data.SqlClient.SqlException will contain not only the error text, but
(inexplicably) all the PRINT statements before it, even ones made from other
stored procedures and triggers. I don't want users seeing these things as it
confuses them. I can't just chop everything off after the first line because
some multi-line error messages are legitimate to parse and pass to users. Is
there any way I can keep PRINT messages out of the exception text, or will I
have to do something ugly like prefix all PRINT statements with a character
I can parse out later?

Paul
Nov 21 '05 #1
0 1424

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve | last post by:
Hi; I went to the microsoft site to try to find a guide to the error messages that the jdbc drivers give ( for sqlserver 2000 ). I had no luck. Does anyone know if there is such a guide? ...
4
by: James | last post by:
Hello All, I have a stored procedure which will act like a main/controller script which will then invoke more stored procedures (~20). Basically, it looks something like below: -- start...
4
by: hb | last post by:
Hi, I got the "System.Data.SqlClient.SqlException: Timeout expired. " error on my web application while saving some data. Would you please tell me how to change the settings in SQL Server...
0
by: Robert Salasidis | last post by:
I am trying to get an email application working in ASP.Net I was trying to use a remote SMTP server (on my web site - but hosted by a third party), but was constantly getting the 'Could not...
3
by: tshad | last post by:
If you get an exception or SqlException, how do you get the actual message? Not the detailed breakdown, but the actual message. For example, in the following message, I would like to find just...
5
by: JuhaM | last post by:
Hi All Just wondering if its possible get more descriptive error messages in to com.ibm.db2.jcc.b.SqlException. getMessge or toString() methods gives only SQL-error codes like: SQLCODE: -1218,...
0
by: =?Utf-8?B?c3RldmVuLnRob21wc29u?= | last post by:
I have a c# web app in which I've recently been seeing some SQLException errors where the message portion of the error is being rendered in Japanese or some other unreadable language (to me at...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.