title: where to put try/catch in 3 tier architecture
body: <p>I have a 3 tier based web application. I want to use I am using try catch block in my business logic layer. Is it right to use try/catch block in business logic or I need to use it in my UI layer?</p>
  
  <p>see my code for DAL.</p>
  
  <pre><code>Data Access Layer
  
  #region Insert in to Logbook
  public int Insert_LogBook(string Vehicle_Number, DateTime Vehicle_Booking_Date, TimeSpan Time_From, TimeSpan Time_To, int KM_Start, int KM_End, string Vehicle_Used_By, string Cost_Code, string Budget_Line, DateTime Entry_Date)
  {
      try
      {
          SqlCommand com = new SqlCommand("Insert_LogBook", con);
          com.Parameters.Add("@Vehicle_Number", SqlDbType.NVarChar, 100).Value = Vehicle_Number;
          com.Parameters.Add("@Vehicle_Booking_Date", SqlDbType.DateTime).Value = Vehicle_Booking_Date;
          com.Parameters.Add("@Time_From", SqlDbType.Time).Value = Time_From;
          com.Parameters.Add("@Time_To", SqlDbType.Time).Value = Time_To;
          com.Parameters.Add("@KM_Start", SqlDbType.Int).Value = KM_Start;
          com.Parameters.Add("@KM_End", SqlDbType.Int).Value = KM_End;
          com.Parameters.Add("@Vehicle_Used_Byr", SqlDbType.VarChar, 100).Value = Vehicle_Used_By;
          com.Parameters.Add("@Cost_Code", SqlDbType.NVarChar, 50).Value = Cost_Code;
          com.Parameters.Add("@Budget_Line", SqlDbType.NVarChar, 50).Value = Budget_Line;
          com.Parameters.Add("@Entry_Date", SqlDbType.DateTime).Value = Entry_Date;
          con.Open();
          int res = com.ExecuteNonQuery();
  
      }
      catch (Exception ex)
      {
          WebMsgBox.Show(ex.Message);
      }
      finally
      {
          con.Close();
          con.Dispose();
  
      }
      return 1;
  }
  #endregion
  </code></pre>
  
  <p>So should I use it in my bal OR IN UI layer or my code is ok. because If I don't use try/catch in my UI layer it won't catch exception (if there is any) and shows the error page.</p>