How can i gets the name of all SQL exceptions? For handling them in my project? Thanks.
A:
There is only one exception type in the System.Data.SqlClient
namespace, and that's SqlException
.
Mark Cidade
2010-09-18 04:43:42
@Mark Cidade:i know this.i mean for example format exception,null refrence exception,or... that maybe occured.
na.fa
2010-09-18 04:48:28
@John Saunders:my first language is persian and i want to show Suitable message in persian,considering the exception details.
na.fa
2010-09-18 05:03:14
@na.fa: `FormatException` and `NullReferenceException` have absolutely nothing to do with SQL.
Timwi
2010-09-18 08:48:51
+3
A:
I think you mean error number. You can get a list of numbers and their descriptions there. However it may not be complete, because different databases may use some additional codes as well.
So in your case you may want to catch SqlException, get its error collection (SqlErrorCollection) and check for Number property in every SqlError of this collection.
UPD: Since you want to translate the error, I think it is better to look for severities (SqlException.Class property) and if you are using MS SQL you can look up that severity in SYSMESSAGES database, it looks that there may be translation already for your language.
negative
2010-09-18 05:06:24
You may also want to take a look at this article (http://www.developer.com/tech/article.php/724711/Microsoft-SQL-Server-2000-Error-Messages.htm). It explains in general ranges of most common sql errors.
negative
2010-09-18 05:19:59