Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8298677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:52:17+00:00 2026-06-08T15:52:17+00:00

This is my DAL, I’m about to try/catch the code and since the concept

  • 0

This is my DAL, I’m about to try/catch the code and since the concept is not that grown in me I have the following doubt.
The one time when it actually does something is in ExecuteSQL method. So, there I’ll have one try/catch. But in GetLinea or UpdateLinea should I also add? I can only think of quite weird errors there.

Also, If you have any suggestions for a cleanup in this code I’d love to hear about it.
Thanks.

namespace DAL
{
    public class Connection
    {
        public string GetNewConnection(string server)
        {
            return ConfigurationManager.ConnectionStrings[server].ConnectionString;
        }

        public DataSet ExecuteSQL(string sp)
        {
            DataSet ds = new DataSet();
            string connectionString = GetNewConnection("BO");
            SqlConnection conn = new SqlConnection(connectionString);
            SqlCommand command = new SqlCommand(sp, conn);
            command.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(command);
            using (conn)
            {
                da.Fill(ds);
            }
            return ds;
        }
    }
    public class LineaDAL
    {
        Connection obj = new Connection();
        public DataSet GetLinea()
        {
            DataSet ds = new DataSet();
            string sp;
            sp = "sp1";
            ds = obj.ExecuteSQL(sp);
            return ds;
        }

        public bool UpdateLinea(string reclamo)
        {
            DataSet ds = new DataSet();
            string sp;
            sp = "sp2";
            ds = obj.ExecuteSQL(sp);
            return ExtensionMethods.IsEmpty(ds);
        }
    }

    public static class ExtensionMethods
    {
        public static bool IsEmpty(this DataSet ds)
        {
            return ds == null ||
              !(from DataTable t in ds.Tables where t.Rows.Count > 0 select t).Any();
        }
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:52:18+00:00Added an answer on June 8, 2026 at 3:52 pm

    As with any exception handling, it really depends on what you are going to do with it. Too often try/catch is used as a way to catch possible bugs just in case. But, really you should have very little try/catch unless you are looking to catch something specific and deal with it properly (notify the user with a custom message for that error). If you do not have anything meaningful to do with the catch, then let it bubble to a top level exception handler. That is my 2 cents at least

    Here is a much more in depth article on exception handling

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my sample code: SPWeb web = SPContext.Current.Web SPList list = web.Lists[TestList]; try
I have simple DAL that consists of a SalesEnquiry object, which includes a List<T>
This is how i have it setup: DAL: a dbml file for the context
This question is regarding the ASP.NET webservice that i am creating using the DAL-BLL
Ok this one is might not have a straight forward answer but lets see.
In my DAL I have a data access object that retrievs database records to
I'm using this code (in my DAL project): ConfigurationManager.AppSettings[server] to access appsettings section in
I am working on project that uses this pattern var businessEntity = new DAL().GetObject(id);
This is my (rough) code (DAL): int i; // Some other declarations SqlCommand myCmdObject
This is my code protected void LoginButton_Click(object sender, EventArgs e) { if (DAL.DAOKullanici.Login(KullaniciTextBox.Text,SifreTextBox.Text)) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.