开发者

Common exceptions while executing sql queries

开发者 https://www.devze.com 2023-01-22 11:00 出处:网络
I have read that catchin开发者_开发技巧g the particular exception separately enhanced the performance so I just wanted to know what are themost common exception that might generate while executing any

I have read that catchin开发者_开发技巧g the particular exception separately enhanced the performance so I just wanted to know what are the most common exception that might generate while executing any sql query


It won't enhance performance, but exception handling provides a good way to control code flow.

The best article (the subject is too long for an SO answer) is "Error Handling in SQL 2005 and Later" by Erland Sommarskog. And shameless plug of my question here

However, if you mean in c# then there is really only SQLException.

As to what causes them, the main ones may be

  • constraint violation (fails CHECK, duplicate/UNIQUE, no parent/FK etc)
  • overflow and conversions (eg -1 to tinyint)
0

精彩评论

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

关注公众号