开发者

Exception handling in windows Application of C# language from Sql Server 2005

开发者 https://www.devze.com 2023-01-26 07:21 出处:网络
I开发者_开发技巧 want List of all types exceptions which may be generated during remotely connection between C# application and sql server2005 like updating, inserting etc..When connected to a Sql Ser

I开发者_开发技巧 want List of all types exceptions which may be generated during remotely connection between C# application and sql server2005 like updating, inserting etc..


When connected to a Sql Server, whenever an exception is thrown, it will be a SqlException.

From documentation:

This class is created whenever the .NET Framework Data Provider for
SQL Server encounters an error generated from the server. 


In the SQL Server instance, a list of all defined error codes is available in the sysmessages table.

SQLException is always thrown when the error originates from the server. The SQLException object will identify which of those errors occurred in its Number property.


Most exceptions that move up from the db layer to the application layer deal with the sqlexception class. In this case, these have to do with the following:

  • time out exceptions
  • incorrect credentials (security)
  • incorrect server name / ip address
  • SQL Server does not exist (etc)

To handle exceptions that are caused by inserts or updates involves exception handling within your actual procedure (sproc). You could also handle these by custom exceptions that you create.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号