Noob: What would be the best way to create an unattended batch process?
I've been tasked to do a program (C# VS-2003) that reads data from ASCII files and uploads them to SQL Server 2000.
I created a WinForm as a demo, where I can select an ASCII file from a folder, process it and upload to SQL Server. There will be different files in the incoming folder of slightly different types, intended for different SQL-Tables.
Job was acomplished and works fine. Now I have to get rid of the visual interface (WinForm) as this will be run daily from a scheduler (logging errors to a file as it wil lrun unattended),
As a newbie to .Net I'm unsure on what would be the best practise here. Should I create it as Console app? Windows Service? other way?
Any advise appreciated.
After some study I realize that a Windows Service may not work for us as it will normally be automatic (i.e. always up and running in the background) and will require a timer to see when to look for incoming files (typically once a day). OTOH a console exe is easy to control and launch from a scheduler, then do its job and gracefully quit.
Just have to make sure I do not leave any MessageBox.Show or other visual code as it will run unattended. Error logs are already output to XML.
Hi Alex,
The only issue with the Console EXE is that someone could easily close it. This will not be so with a Windows Service since there is no UI exposed on the desltop. However, if this is a controlled environment then I dont think that would be an issue.
Also remember that a console app or a windows form app runs as the logged on interactive user and a service can be easily configured to run under any account.
Regards,
Vikram
I think the best approach is to write this entirely within SQL Server, using bcp which is designed precisely for this purpose - importing data from files.
You can then schedule the bcp job using the scheduler built into SQL Server.
This would be the most efficient and fastest solution.