Solved

How to implement exception handling in a 3 tier web app

Posted on 2011-02-10
3
388 Views
Last Modified: 2012-05-11
Hi,

I am new to the 3 tier development architecture and am looking to see what is the most common and efficient way to create error handling. Is it by creating a custom error handling object? Any help is much appreciated!
0
Comment
Question by:bschave2
3 Comments
 
LVL 18

Accepted Solution

by:
Anil Golamari earned 500 total points
ID: 34865532
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34865607
It depends entirely on what you need to do and what you need to report to the upper tiers. Trapping exceptions where they happen is usually best, and you will of course want to log them. You can then either re-throw the exception to, for example, let your UI know something went wrong. But whether you rethrow the original exception, or a more generic custom exception type is up to you.
0
 

Author Comment

by:bschave2
ID: 34866854
How can I pass the exception back to the UIl?

well say in the UIL I call an object in the UIL

BLL customers = new BLL();
customers.GetCustomers(gvCustomers);

in the BLL method I get the gridview:

public void GetCustomers(GridView gvCustomers)
    {

        DLL getGV = new DLL();
        gvCustomers.DataSource = getGV.getDS("getCusts");
        gvCustomers.DataBind();
    }

And in the DLL i have the method as

public DataSet getDS(string ProcName, SortedList<string, string> sqlParams)
    {
        try
        {
            getCon();
            cmd = new SqlCommand(ProcName, con);

            //Looping through params.
            foreach (KeyValuePair<string, string> Param in sqlParams)
            {
                cmd.Parameters.AddWithValue(Param.Key.ToString(), Param.Value.ToString());

            }
            da = new SqlDataAdapter(cmd);
            cmd.CommandType = CommandType.StoredProcedure;
            ds = new DataSet();
            da.Fill(ds);

            closeCon();
        }
        catch (SqlException sqlex)
        {
            throw new Exception(ex.message);
        }

        return ds;
    }
0

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
Linq Help 1 35
Error on link 14 38
Make an ajax call ithat alters url and updates a listview in asp.net 1 22
C# guarantee sql connection close 6 25
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

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

16 Experts available now in Live!

Get 1:1 Help Now