开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜