Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

This is something ive never done before so i apologise if this is a silly question.

I have a c# console app which when ran locally it works perfectly. However, when I try and run it from task scheduler part of it runs but it wont write to the SQL database.

My folder has permissions to read and write. Also the task is running as administrator and with the highest privileges. When I check the task history it says its complete with no errors.

Any help would be appreciated

Thanks

What I have tried:

My folder has permissions to read and write. Also the task is running as administrator and with the highest privileges.  When I check the task history it says its complete with no errors.
Posted
Updated 15-Jan-19 5:08am

One reason causing this could be difference in authentication. If you're using Windows authentication for SQL Server then when you're running the application from Windows session it's using your credentials. When you're running it using Task Scheduler you define which credentials are used.

So instead of using administrator account, perhaps you can use your account setting or if necessary create a separate account which will be used for the scheduled task.

Just to prevent misunderstandings, writing to a SQL database does not require access to the folders containing the database files. Typically these folders are not even visible to users of the database.

What comes to the outcome of the program, Task Scheduler shows if the application has execute successfully or not.You need to 'publish' the errors one way or another for them to be visible from outside. For example you can
- use a return code for the application
- write to a log file
- write to event log etc..
 
Share this answer
 
v2
If this is about SQL Server, you probably need to add administrator as a user or modify the settings, see article here: Create a Database User - SQL Server | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900