Last post Sep 05, 2013 05:17 PM by hans_v
Sep 05, 2013 11:39 AM|ghirst|LINK
Question: How do I automate vb.net based on a timer with no user interaction
I am looking to create a weekly report and email the client.
I have a report that is generated manually with date select so all that code is sorted. The only part I have read alot about and am struggling to not find old articles on (http://www.codeproject.com/Articles/3990/Simple-Windows-Service-Sample)
is the best way to schedule code to run once a week automatically.
I use VB.net and have access to the SQL management and IIS.
Basically what is the best practise to do this, there seems to be a few global.asax ways but then that is reliant on visitors.
I have put some code below to show a bit of research!
<%@ Application Language="VB" %>
<%@ Import Namespace="System.Threading" %>
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
If DayOfWeek.thursday = DateTime.Now.DayOfWeek AndAlso 15 = DateTime.Now.Hour Then
Session.Item("Test") = "Between 3 and 4pm"
Session.Item("Test") = "Not between 3 and 4pm"
' Execute update here
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
SELECT distinct [userfirstname], [UserSurname] FROM [dbo].[tblResults]
where [ModuleDateStart] <= @dateStart and [ModuleDateStart] >= @dateEnd
GROUP BY [UserFirstName], [UserSurname]
order by [UserSurname] asc;
' Note: The Session_End event is raised only when the sessionstate mode
' is set to InProc in the Web.config file. If session mode is set to StateServer
' or SQLServer, the event is not raised.
the actual query...
Sep 05, 2013 03:15 PM|ignatandrei|LINK
a Console application run by task scheduler
Sep 05, 2013 04:59 PM|ghirst|LINK
Such as this... ? http://www.codeguru.com/csharp/.net/article.php/c19529/Building-a-NET-Console-Application-for-Scheduled-Tasks.htm
Sep 05, 2013 05:17 PM|hans_v|LINK
If a console Application or Windows Service are not an option: