retreive data from access - try and catch?

Posted on 2006-11-07
Last Modified: 2010-04-16
I am building pages similiar to the concept behind this page listed here.;EN-US;q308100&GSSNB=1
I was wondering if try and catch statements should be used in the pages, I always though it is standard practice to include this. Why isnt it used in this example?
What is the strandard protocol and process for this?

Or does it not merrit adding this since  its just a query of data?

Question by:chicabow
  • 3
  • 2
LVL 52

Expert Comment

by:Carl Tawn
ID: 17890128
Because they're being lazy :o)

You'll find a lot of samples don't bother putting the try...catch in there so that you concentrate on the specific concept they are trying to demonstrate.

Author Comment

ID: 17959953
Looking for some more concrete answer if possible anyone?
LVL 52

Accepted Solution

Carl Tawn earned 50 total points
ID: 17961119
What more do you need to know ?

Ordinarily you would add a try...catch around any database access code due to its nature and the myriad of things that can go wrong:

    SqlConnection cn = new SqlConnection("Connection string");

          // Other database access code
    catch (SqlException ex)
         // Report and/or log the exception
         if (cn.ConnectionState != ConnectionState.Closed)

As I mentioned earlier, most of the Microsoft samples don't include try...catch code simply for brevity and just stick to demonstrating the specific point in question.
LVL 52

Expert Comment

by:Carl Tawn
ID: 17961129
Slight correction:

         if (cn.State != ConnectionState.Closed)

Author Comment

ID: 18127723
Thanks for the reminder, these are helpful for people who foget to close them out.

Thanks Carl_Tawn

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Data Saving 5 56
fomat Json objects 6 28
Icons and Colors for Terms 3 24
Please explain "Multi-Tenant Services" 5 63
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now