473,657 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Sql Client.SqlExcep tion, 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.Sql Client.SqlExcep tion 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 1437

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

Similar topics

5
10397
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? I got this mysterious error message below in my logs ( nothing visible
4
14751
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 script create procedure ... print 'process started' exec sp_1
4
17985
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 2000 or IIS to increase the timeout?
0
1732
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 access 'CDO.Message' Object ' message. I tried all teh suggestions I could find on Google, ut was unable to get it to work. In the end I decided to use my local host (using my local IP address.
3
511
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 "Incorrect syntax near the keyword 'and'." or "System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'and'." instead of:
5
19647
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, SQLSTATE: 57011, SQLERRMC: 4096 I am using universal driver... Thanks for any help
0
1177
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 least). Most of the time I refresh the screen and the error goes away. It's very bizarre, yet concerning. Here's an example from the event log on my machine: Exception Type: System.Data.SqlClient.SqlException Errors:...
2
19457
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
2897
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
8316
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.