Reputation: 4010
HI all, I have a WPF based POS software and have more than 100 Stored procedure in SQL Server 2005 Express Database. I am using DAL for database connectivity. This app is designed to be able to bill from LAN clients so ConnectionString points to Database server IP. For this reason I have called all SP (and related logic like displaying data on gridview etc.) in try catch block. Will this slow down my app, Is extensive use or try catch not good for any app.
Can you suggest me any other way to handle error from LAN client DB connectivity.
Thank you RAJ K
Upvotes: 2
Views: 817
Reputation: 5086
It will not slow down the performance in this context. It would slow down if you called the function containing try/catch 1000 of times repeatedly.
Upvotes: 0
Reputation: 932
In my opinion, trycatch should always be used to handle errors you cant forsee (like files or connection manipulation). If it is something you can control (like X character in a string), this should be done via validations.
About the speed, I dont think it slow it down.
Upvotes: 1
Reputation: 39480
Using try/catch blocks won't appreciably slow down your application. I suspect you would be well served by using transactions on your database, as well.
Upvotes: 0
Reputation: 53699
No, try/catch is not necesarily slow unless an exception is actually thrown. And since you should only have exceptions in exceptional circumstances, there should be little impact on the performance of your program due to the use of try/catch.
Upvotes: 2