Thomas Post
Thomas Post

Reputation: 545

dynamics AX batch job through ODBC

I have problems with an ODBC connection used in a batch job: when executed, I have the following error message :

"The ODBC operation failed.Unable to connect to database Invalid connection String attribute Trusted_Connection Unabe to create object 'OdbcConnection' "

I try to connect to an Access database, I use the following code:

LoginProperty                 loginProperty;
OdbcConnection                odbcConnection;
;
loginProperty = new LoginProperty();
loginProperty.setDSN("MyDSN");
loginProperty.setDatabase("MyDatabase");

odbcConnection = new OdbcConnection(loginProperty);

when debugging, it crashes on odbcConnection = new OdbcConnection(loginProperty). I tested the same code in a job in local client execution, there was no problem and it worked fine(without defining login password in code or DSN). My DSN seems to be OK on AOS, I'm using AX 2009 without SP1, I saw some examples where there was login/password defined in loginProperty object , the setUserName() and setPassword() methods are not available in my AX version loginProperty object. My class is executed on server-side (as any batch job).

Is there some particular setup to do to connect to ODBC datasource through batch job?

any ideas or suggestions?

thanks for your help

Edit:AOS is running on Windows server 2003 32 bits, ODBC tested on it, works fine but doesn't work in AX through batch job

Upvotes: 3

Views: 2644

Answers (3)

Rob
Rob

Reputation: 21

If you are on a 64 bit machine use C:\Windows\SysWOW64\odbca32.exe to create the datasource. Check under which ID the AOS runs, log on with that ID and make sure you can 'see' the data source. Also make sure that the AOS account has access to the directory/files (if using file-based odbc)

Upvotes: 1

j.a.estevan
j.a.estevan

Reputation: 3097

It may be caused due to permisions. "trusted connection" refers to the fact that you connect to the database through the user logged to the current session. When you run a Job from the AX client, this is executed with the user that runs the current AX client (the one logged to the active session); When code is executed from server in a batch job, code is executed through the user that runs the AOS windows service.

Has this user permissions to read/write/access the access file and directory?

Upvotes: 1

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18061

Most likely you will need a 32-bit DSN connection for your AX. I would create both versions on the AOS server.

Look here for details.

Upvotes: 3

Related Questions