web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

ADO and NAV 2017 task scheduler

(0) ShareShare
ReportReport
Posted on by 4

I made an automated job which manipulates data in another SQL database. It worked fine in NAV 2009 but now I can't get it to start using the new task scheduler in NAV 2017. It works fine if I run it manually but when running it in a job queue entry using the task scheduler all I get is Cannot create ADO Connection Automation variable.

Is there any way to get this working without having to rewrite everything using dot net objects?

IF ISCLEAR(ADOConnection) THEN BEGIN

IF NOT CREATE(ADOConnection, false, TRUE) THEN BEGIN
ERROR('Cannot create ADO Connection automation variable.');
END;
END;

IF ISCLEAR(ADORecSet) THEN BEGIN
IF NOT CREATE(ADORecSet, false, TRUE) THEN BEGIN
ERROR('Cannot create ADO Recordset automation variable.');
END;
END;

IF ISCLEAR(ADOStream) THEN BEGIN
IF NOT CREATE(ADOStream, false, TRUE) THEN BEGIN
ERROR('Cannot create ADO Stream automation variable.');
END;
END;

ADOConnection.ConnectionString('Provider=SQLOLEDB;Data Source=ZZZZ;'
+ 'Initial Catalog=' + "Database Name" + ';User ID=YYYY;Password=XXXX;');
ADOConnection.Open;
RecordsAffected := '';
RSOption := 0;

SQLString := <somesqlstring>
WriteQuery(SQLString);

ADORecSet := ADOConnection.Execute(SQLString);
ADOConnection.Close;


*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Check Permission of Service User Account

  • Rashed Profile Picture
    3,765 on at

    Your line

    CREATE(ADOConnection, false, TRUE) 

    needs to be changed to

    CREATE(ADOConnection, false, false)

    There is no client for the job queue.

  • CU19050727-1 Profile Picture
    4 on at

    I have tried logging into the server with the service account and run the job manually just to set all security questions to Always allow. There should be no permission error since I can run the job manually.

    Changing it to false, false gives compilation error: "You cannot create an Automation object "ADOConnection" on Microsoft NAV Server. You must create it on a client computer."

  • Verified answer
    Rashed Profile Picture
    3,765 on at

    You need to change it from Automation to dotNET Type.   There are many examples on how to do it.

    ADOConnection := ADOConnection.SqlConnection(txtConnection);
    ADOConnection.Open;
    ADOCommand := ADOConnection.CreateCommand();
    
    ADOCommand.CommandText := QueryCommand;
    ADOCommand.CommandTimeout := 2000;
    ADOCommand.ExecuteScalar;
    
    ADOConnection.Close;
    CLEAR(ADOConnection);
    CLEAR(ADOCommand);
    
    
    Name	DataType	Subtype	Length
    ADOConnection	DotNet	System.Data.SqlClient.SqlConnection.'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'	
    ADOCommand	DotNet	System.Data.SqlClient.SqlCommand.'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'	


  • CU19050727-1 Profile Picture
    4 on at

    I was just about to create a reply that I used your article to change the code to .net

    It works great, thanks a lot for the answer and your super article: community.dynamics.com/.../using-ado-on-rtc-in-nav

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans