CSharpSuzie
CSharpSuzie

Reputation: 287

Run SQL queries at predefined time

I am new to C#.

I have to write an application that would automatically run multiple predefined sql queries on multiple predefined databases at the same time every day. The application then has to take this information from the queries and compile it into 1 form/report, and then send this form/report to a predefined e-mail address. All this must happen automatically every day at the same time.

I do know how to connect to a database and run queries on it in a C# application; I also know how to e-mail a form/ report from within a C# application.

My questions are:

  1. How would it be possible to have this application run automatically at a predefined time every day?
  2. How would I compile all this information into 1 form/report (I am using multiple databases and multiple queries)

I take it that this might be a console application?

I can’t find any references to this anywhere. Any help would really be much appreciated.

Thanks in advance!

Upvotes: 0

Views: 581

Answers (3)

MeelStorm
MeelStorm

Reputation: 634

You can shedule a task for windows http://support.microsoft.com/kb/308569 And you can megrge infogmation from several DataTables

Upvotes: 0

Toby Allen
Toby Allen

Reputation: 11213

Windows scheduler or a unix cron job to run your app at a certain time is the usual way.

Upvotes: 2

alexn
alexn

Reputation: 58962

Don't try to build this logic yourself. I've done it a couple of times and it's just not worth it.

  1. You should use the built in Windows Scheduler for this. You can set up when your application should run, how often it should reccur and much more. A console application or Windows service will do just fine.

  2. This is hard to answer without knowing how your application is structured.Can't you just run your queries and combine the results into a report?

Upvotes: 2

Related Questions