none
Windows task scheduler wont write to SQL database from C# console app RRS feed

  • Question

  • 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
    Tuesday, January 15, 2019 11:18 AM

All replies

  • Hello,

    Have you made any attempts and debugging the service to where the write operations occurs? By debugging this would mean writing to the event log, see if there are any exceptions thrown if in a try/catch statement.

    Something like this


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, January 15, 2019 11:30 AM
    Moderator
  • My gut instinct is a logic error in your app. As Karen mentioned, using logging in your app would help identify things. Also ensure that you're not eating exceptions (something that seems common in console apps).

    Verify the account under which the task is running has the necessary permissions to talk to the DB. Note that the account you're running your task under isn't relevant unless you're using Windows auth in your connection string.


    Michael Taylor http://www.michaeltaylorp3.net

    Tuesday, January 15, 2019 2:59 PM
    Moderator
  • Hi user1666,

    Thank you for posting here.

    Further to your issue, I make a simple code , I use the task scheduler to run it, it works well.

    You could check if the data that you wrote to database is the same as the next data.

    If so, you could set try/catch to output the exception.

    If it exists the problem, please share the related code to reproduce your problem via OneDrive.

    Hope my advice could be helpful.

    Best regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 17, 2019 9:51 AM
    Moderator