I am having problem trying to connect to an external database with Microsoft Dynamics AX.
I have configured the dsn, and i can connect with sql server authentication (not active directory, because is in another server), and when i test, it just works.
But when i try to use the dsn in x++ i am sending the correct user and password to the loginProperty, but always return error, it try to do with the active directory user.
This is my code:
LoginProperty loginProperty;
OdbcConnection odbcConnection;
Statement statement;
ResultSet resultSet;
str sql, criteria;
SqlStatementExecutePermission perm;
TLExternalUser tlExternaUser;
TLExternalUserPwd tlExternalUserPwd;
str strConnectionString;
str dsn = "myDsnName";
str dsnUser = "sqlUser";
str dsnUSerPwd = "sqlPWD";
strConnectionString = strfmt("UID=%1;PWD=%2",dsnUser,dsnUSerPwd);
loginProperty = new LoginProperty();
loginProperty.setDSN(dsn);
loginProperty.setDatabase("MyDatabase");
loginProperty.setOther(strConnectionString);
odbcConnection = new OdbcConnection(loginProperty);
if (odbcConnection)
{
info("success");
}
else
{
throw error("Failed to log on to the database through ODBC.");
}
But i am getting this error:
[Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'DOMAIN\ACTIVEDIRECTORYUSER'.
I was looging to pass directly to my loginProperty the username and password, but such methods does not exist.
How can i make it works?
I can not make it works with dsn, so i use server, in this way:
LoginProperty loginProperty;
OdbcConnection odbcConnection;
Statement statement;
ResultSet resultSet;
str sql ;
SqlStatementExecutePermission perm;
TLExternalUser tlExternaUser;
TLExternalUserPwd tlExternalUserPwd;
str strConnectionString;
str dbServer = 'myipServer';
str serverDbUser = 'myUser';
str serverDbUserPwd = 'MyPassword';
strConnectionString = strfmt("UID=%1;PWD=%2",serverDbUser,serverDbUserPwd);
loginProperty = new LoginProperty();
loginProperty.setServer(dbServer);
loginProperty.setDatabase("MyDatabase");
loginProperty.setOther(strConnectionString);
odbcConnection = new OdbcConnection(loginProperty);
I do not understand why with dsn does not work