Technodrone

there's some good in this world, Mr. Frodo... and it's worth fighting for.

  Home  |   Contact  |   Syndication    |   Login
  14 Posts | 2 Stories | 37 Comments | 0 Trackbacks

News

Article Categories

Archives

Post Categories

Image Galleries

Code hacks

Face Book Profile

LinkedIn Profile

Recommended Products

Tuesday, August 05, 2008 #

Business owners wanted a report with a hard coded date range rather than a date range prompt. Customer is always right, especially in an economic downturn.   I could not figure out how to do this and after a couple of days of trial and error I got this to work.  I hope this saves someone some time.

--get past 30 days
[Business View].[Sales Tracking Transaction].[Sale Date]between _add_days(current_date,-30) and current_date

--get past year
[Business View].[Sales Tracking Transaction].[Sale Date]between _add_Years(current_date,-1) and current_date


If detailed error logging is needed you can use the following to get the page name as well as the method name that triggered the error. In my case I log errors to the event log as well as store them in the database using log4net. I like getting back detailed error messages so I can more easily find and fix the related bugs.

using System.Diagnostics;

using System. Reflection:

 catch (Exception ex)

{

//retrieves the name of the page so it does not have to be hardcoded
string currentPageName = System.IO.Path.GetFileName(Request.PhysicalPath);

StackFrame stackFrame = new StackFrame();

//retrieves the name of the current method so it does not have to be hardcoded
MethodBase methodBase = stackFrame.GetMethod();

logger.Error(String.Format("Page Name: {1}: There was an error in the Method: {2}, User ID: {0})",
UserID, currentPageName, methodBase.Name), ex);

}