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 AX (Archived)

ODBC connection Error when trying to Insert data using Batch job

(0) ShareShare
ReportReport
Posted on by 106

Dear Friends,

I wrote a method to insert the data into two fields in Cust table, then I added the method to a class which extends RunBaseBatch.

When the batch scheduled in DEV and Test , batch executed successfully and records got inserted, but in production the batch got failed with the below error.

"ODBC operation failed.Unable to log on to the database.

[Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'XXXX\AX.AOS1'.

Object 'OdbcConnection' could not be created"

 

I have verified permissions for AX.AOS1 in DEV and PROD and both having similar access.

Can someone please advise me the possible solution for this issue?

Thanks

Mohan

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Why do you need ODBC for writing to CustTable? It sounds not only unnecessary, but also dangerous (security risks, bypassing caching, bypassing logic on insert, bypassing alerts...).

  • Mohan_AX Profile Picture
    106 on at

    Thank you Martin for the response.

    I am not referring to ODBC connection any where in my code (pasted below) , also when I ran manually the error not displayed only in Batch mode I am seeing the error, please advise.

    //

    public void processRecords()

    {

       CustTable obl;

       int check_id = 0;

       int cnt_rec = 0;

       int64 rec_id;

       str segment_id;

       str subsegment_id;

       ResultSet res;

       str sql;

       sql = "select * from vw_account_CSM_Manager";

       res = XXXSqlUtility::getSQLResultSet("AXPROD1", "ax_staging", sql);

       while (res.next())

       {

           try {

               rec_id = res.getInt64(2);

               segment_id = res.getString(3);

               subsegment_id = res.getString(4);

               switch(check_id) {

                   case 0:

                       select forUpdate obl where obl.RecId == rec_id;

                       obl.segmentid = segment_id;

                       obl.subsegmentid = subsegment_id;

                       obl.modifiedField(FieldNum(CustTable, segmentid));

                       obl.modifiedField(FieldNum(CustTable, subsegmentid));

                       obl.update();

                       info("Updated: " +int642str(rec_id));

                       break;

               }

               cnt_rec++;

           } catch {

               info("Failed: "+int642str(rec_id));

           }

       }

    }

  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    You don't see it only because you aren't looking at the right place. When you debug your code, you'll find that the error is thrown somewhere in XXXSqlUtility::getSQLResultSet().

    I can only guess what the method does. If "ax_staging" is a database name, it means that XXXX\AX.AOS1 doesn't have permissions to log into "ax_staging" database.

  • Verified answer
    Mohan_AX Profile Picture
    106 on at

    Perfect, this gives me a good clue to investigate further , thank you very much Martin.

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 AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans