473,432 Members | 1,809 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,432 software developers and data experts.

What SqlExceptions can be thrown

to my application?

In my web service, I'm using the Sql Data provider for .NET. I put the code
that sets up parameters, my call to Connection.Open(), and to
Command.ExecuteNonQuery() in a try block, then catch SqlException.

The problem is, I have been unable to determine what SqlExceptions might be
thrown to my app, and what they might mean. Specifically, I need to know
whether or not the stored procedure I just ran executed successfully. Is
there any place I can look this up?

Thanks in advance.
Nov 17 '05 #1
4 1549
Diane,

If all you need to know is if the stored procedure you ran completed
successfully, then all you have to do is determine whether or not there was
an exception, if not, then the command succeeded.

As for what SqlExceptions might be thrown, the SqlException class will
have more information based on the specific errors that SQL server returns.
In the end though, it's that one exception that is thrown, with additional
information.

Is there a particular error that you are trying to catch from SQL
server? If so check the Errors property on the exception instance and then
look at the Number property of the individual errors, checking against the
specific errors you are looking for.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Diane Droubay" <Diane Dr*****@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
to my application?

In my web service, I'm using the Sql Data provider for .NET. I put the
code
that sets up parameters, my call to Connection.Open(), and to
Command.ExecuteNonQuery() in a try block, then catch SqlException.

The problem is, I have been unable to determine what SqlExceptions might
be
thrown to my app, and what they might mean. Specifically, I need to know
whether or not the stored procedure I just ran executed successfully. Is
there any place I can look this up?

Thanks in advance.

Nov 17 '05 #2
Thanks. So, it would be safe to assume that for some reason or another that
my stored procedure failed, and I could just log it and deal with the
failure. There is no case where a SqlException exception would be
informational, but not indicate a complete failure?

Diane

"Nicholas Paldino [.NET/C# MVP]" wrote:
Diane,

If all you need to know is if the stored procedure you ran completed
successfully, then all you have to do is determine whether or not there was
an exception, if not, then the command succeeded.

As for what SqlExceptions might be thrown, the SqlException class will
have more information based on the specific errors that SQL server returns.
In the end though, it's that one exception that is thrown, with additional
information.

Is there a particular error that you are trying to catch from SQL
server? If so check the Errors property on the exception instance and then
look at the Number property of the individual errors, checking against the
specific errors you are looking for.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Diane Droubay" <Diane Dr*****@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
to my application?

In my web service, I'm using the Sql Data provider for .NET. I put the
code
that sets up parameters, my call to Connection.Open(), and to
Command.ExecuteNonQuery() in a try block, then catch SqlException.

The problem is, I have been unable to determine what SqlExceptions might
be
thrown to my app, and what they might mean. Specifically, I need to know
whether or not the stored procedure I just ran executed successfully. Is
there any place I can look this up?

Thanks in advance.


Nov 17 '05 #3
<"=?Utf-8?B?RGlhbmUgRHJvdWJheQ==?=" <Diane
Dr*****@discussions.microsoft.com>> wrote:
Thanks. So, it would be safe to assume that for some reason or another that
my stored procedure failed, and I could just log it and deal with the
failure. There is no case where a SqlException exception would be
informational, but not indicate a complete failure?


That depends. Your stored procedure could have detected the failure
itself and corrected the problem, potentially. Unfortunately, with SQL
Server 2000 I don't believe it could then stop the exception from
bubbling up to your .NET code.

If you end up in this situation, you could make the stored procedure
have an out parameter which indicated what the SP thought in terms of
success/failure.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4
This helps. Thanks!

"Jon Skeet [C# MVP]" wrote:
<"=?Utf-8?B?RGlhbmUgRHJvdWJheQ==?=" <Diane
Dr*****@discussions.microsoft.com>> wrote:
Thanks. So, it would be safe to assume that for some reason or another that
my stored procedure failed, and I could just log it and deal with the
failure. There is no case where a SqlException exception would be
informational, but not indicate a complete failure?


That depends. Your stored procedure could have detected the failure
itself and corrected the problem, potentially. Unfortunately, with SQL
Server 2000 I don't believe it could then stop the exception from
bubbling up to your .NET code.

If you end up in this situation, you could make the stored procedure
have an out parameter which indicated what the SP thought in terms of
success/failure.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #5

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

Similar topics

5
by: Ken | last post by:
Hi. I know it is recommended that exceptions should be caught by reference, but are there recommendations for how an exception should be thrown? Or is it just a matter of throwing a type that is...
24
by: Steven T. Hatton | last post by:
If I understand correctly, I have no assurance that I can determine the type of a simple class instance thrown as an exception unless I explicitly catch it by name. (non-derived classes having no...
24
by: Dave | last post by:
Maybe I'm missing something here, but I can't see the purpose of the 'finally' keyword. What is the difference between: try { doSomething() } catch { handleError(); }
4
by: Rob Richardson | last post by:
Greetings! I am working on an application that targets a Pocket PC running Windows CE and SQL Server CE. Almost all functions in the application use a Try block with a Catch block that looks...
6
by: **Developer** | last post by:
What does this mean: External component has thrown an exception. My program crashes after it leaves a subroutine. What I see during debugging is when I press F11 at the End Sub statement
2
by: SharpCoderMP | last post by:
I'm having troubles with uploading files to the ftp server using FtpWebRequest. I occasionally get an Exception saying: "The underlying connection was closed: An unexpected error occurred on a...
2
by: Zytan | last post by:
I know that WebRequest.GetResponse can throw WebException from internet tutorials. However in the MSDN docs: http://msdn2.microsoft.com/en-us/library/system.net.webrequest.getresponse.aspx It...
6
by: Ken Fine | last post by:
This is a basic question. What is the difference between casting and using the Convert.ToXXX methods, from the standpoint of the compiler, in terms of performance, and in other ways? e.g. ...
16
by: HillBilly | last post by:
This is freaking me out. I'm using Membership and trying to determine if the database is online. The GetConnectionString( ) method returns a connection string as expected but not when used in the...
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
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...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.