Hi
I have below code . I want if error is encountered in catch statement then some message should be returned
public List<Location> GetAllLocation() { List<Location> objLocation = new List<Location>(); try { using (SqlConnection con = new SqlConnection(Common.Con)) { con.Open(); SqlCommand cmd = new SqlCommand("sp_Location", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "R"); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { objLocation.Add(new Location { Id = rdr["Id"].ToString(), Description = rdr["Description"].ToString(), GstStateCode = rdr["GstStateCode"].ToString(), GstStateName = rdr["GstStateName"].ToString(), GstNo = rdr["GstNo"].ToString(), IsActive = Convert.ToBoolean(rdr["IsActive"]), }); } //return objLocation; } } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex); } return objLocation; }
Thanks