tag:blogger.com,1999:blog-6082652835152798567.post1439665096308161661..comments2024-03-28T21:41:58.974-07:00Comments on Sql server, .net and c# video tutorial: SQLConnection in ADO.NET - Part 2Unknownnoreply@blogger.comBlogger7125tag:blogger.com,1999:blog-6082652835152798567.post-14284898238049211312016-09-01T00:10:34.093-07:002016-09-01T00:10:34.093-07:00The database connection are handled in try catch b...The database connection are handled in try catch block .. bcoz if there is any exception like database name spelled wrong or wrong connection name etc .. during these consequences it throws an exception if it is not handled in try catch block.. <br /><br />Throwing an exception is bad in any application bcoz it can display the confidential informations and the NON-IT users cannot understand whats happening, so they do not visit ur application again,,Rajendra Prasad C Shttps://www.blogger.com/profile/17875055263930674992noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-25634411371724870992016-03-19T23:42:54.529-07:002016-03-19T23:42:54.529-07:00Hello Venkat Sir,
Can you please provide some inf...Hello Venkat Sir,<br /><br />Can you please provide some information about "SQL Server Connection Pooling". I recently heard that opening and Closing connection is not a good approach and hence uses Connection pooling. <br />Can you please please provide some inputs about this? <br />Thanks as always!!!! Anonymoushttps://www.blogger.com/profile/10696324100878977889noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-26309011873454707972015-03-22T03:39:16.144-07:002015-03-22T03:39:16.144-07:00Thanks for this nice and neat articleThanks for this nice and neat articleOsa Hadyhttps://www.blogger.com/profile/16166859923481924064noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-26235335953246150482014-12-18T03:39:40.917-08:002014-12-18T03:39:40.917-08:00MR.... PERFECT is Venkat.....Venkat.......Venkat....MR.... PERFECT is Venkat.....Venkat.......Venkat.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-32079172249952446132014-10-18T10:32:08.734-07:002014-10-18T10:32:08.734-07:00Hi Reddy,
This is a very good question. Thanks fo...Hi Reddy,<br /><br />This is a very good question. Thanks for asking.<br /><br />Irerespective of whether there is an exception or not the connection gets closed when the using block is exited. So this means the connection is guaranteed to close.<br /><br />Depending on the application architecture and type of exception there are several ways to handle the exceptions. If the exceptions are handled and logged at the application level in Global.asax or in a base page, I will let the exception bubble up and let the handler handle and log it.<br /><br />However, if there is a situation where you want to handle the exception and provide an error message to the end user so he can correct and resubmit the form, then you can handle exceptions locally still with using block as shown below. <br /><br />using (SqlConnection connection = new SqlConnection(connectionString)) <br />{ <br /> try <br /> {<br /> connection.Open();<br /> // Code that could throw exceptions <br /> } <br /> catch (Exception) <br /> { <br /> // Handle exception<br /> }<br />}<br /><br />Hope this answers your question.<br />VenkatVenkathttps://www.blogger.com/profile/11295753737388828672noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-81572342464653084972014-10-14T19:43:03.784-07:002014-10-14T19:43:03.784-07:00Hi Venkat Sir,
I faced one interview question, in...Hi Venkat Sir,<br /><br />I faced one interview question, instead of try catch block, we can use "Using" keyword to close the connection automatically.<br /><br /><br />As you said " We don't have to explicitly call Close() method, when using is used. The connection will be automatically closed for us."<br /><br />They asked me, how do you handle if you get any exception?<br /><br />Kindly answer me..<br /><br />Regards<br />Reddy A<br />Bangalore<br /><br />Reddyhttps://www.blogger.com/profile/17720857742751109289noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-30099334581200319832013-07-05T04:45:49.715-07:002013-07-05T04:45:49.715-07:00most i have seen on internet code database connect...most i have seen on internet code database connection are connected under the exception.why?Anonymousnoreply@blogger.com