Help For A Newbie - Service to sql script to a csv - simple right!

CharlesWh

Member
Joined
Aug 17, 2011
Messages
5
Programming Experience
Beginner
Hi All,

I am a newbie to Visual Studio; i have downloaded a 90 day trial. I want to write a Windows Service. It will periodically ( on timer) select data from one SQL Db and create a CSV file.


Key questions:


The Db where data is taken from is a variable and will require a config file to set the Db name/instance
Timer will be a variable

But in simple terms what process/development is required.


Thanks
 
Create a System.Timers.Timer, either in the designer or in code. In the OnStart method, set the Interval from the config file, set AutoReset to True and call Start. In the Elapsed event handler, get your connection string from the config file, query the database to populate a DataTable and then use a StreamWriter with two nested loops to write out the data to the file. That's probably less than an hour's work, including all testing, if you know what you're doing.
 
Back
Top