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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

OdbcConnection object

(0) ShareShare
ReportReport
Posted on by

Hello,

I am using an odbc connection to connect extenral database, not ax.

For some reason, I got that the current user is failed to login, even the odbc string is not the current user, and I successfully connect to the database by odbc (in control panel - system admin tools).

It seems that I need to declare the windows user in the database, but I don't want to do that.

How can I overcome this problem?

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Douglas Noel Profile Picture
    3,905 on at
    RE: OdbcConnection object

    Hi,

    I think you can only pass username/password  using sql-server authentification enabled.

    Using integrated securrity the user/password combination is ignored - to my knowledge.

    And I'm not sure if you can mix integrated security option and trusted connection option.

    Using trusted connection using odbc data provider I think you can only use yes and no, not true and false

    Have you tried Dsn=<YOURDSN>;Trusted_Connection=no;uid=<uid>;pwd=<pid>

    take a look at:

    blogs.msdn.com/.../connectionstrings-mixing-usernames-and-windows-authentication-who-goes-first.aspx

    sorry, really no other idea.

    It's really old but sounds interesting.

    regrads

    Douglas

  • Community Member Profile Picture
    on at
    RE: OdbcConnection object

    I have tried this.

    Still have the same problem (with the second and current windows user, which is not "sa" user).

    I did try connection string like:

    'dsn=mydsn;Integrated Security=false;Trusted_Connection=True;'

    Also, I realized that the connectionStringBuilder make a string with "user id=xxx;password=yyy" while when I did in c#, the string is "uid=xxx;pwd=xxx"; I succeed connect in C# with no problem, also connect by server explorer without any problem.

    I presume there are differences between versions, since the the AX sql version is 11.0.3128 and the other db version is 10.50.2500.

    Is there any other odbcconnection class that I can use?

    Thanks :)

  • Suggested answer
    Anton Venter Profile Picture
    20,273 Super User 2025 Season 2 on at
    RE: OdbcConnection object

    Hi Eitan, this is what I mean with the integrated security part.

        LoginProperty loginProperty = new LoginProperty();
        System.Data.SqlClient.SqlConnectionStringBuilder connectionStringBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder();
        
    
        connectionStringBuilder.set_UserID("sa");
        connectionStringBuilder.set_Password("password123");
        connectionStringBuilder.set_IntegratedSecurity(false);
        
        loginProperty.setOther(connectionStringBuilder.ToString());


  • Community Member Profile Picture
    on at
    RE: OdbcConnection object

    Don't know - where is it?

  • Suggested answer
    Anton Venter Profile Picture
    20,273 Super User 2025 Season 2 on at
    RE: OdbcConnection object

    You have to specify somewhere that integrated security = no. Do you have that?

  • Community Member Profile Picture
    on at
    RE: OdbcConnection object

    Yes, I know that solution, but that's the problem:

    There is check for the user I pass to loginproperty, and there is another check for the current windows's user.

    I check also connecting to odbc in C#, and it work fine (no double check for the two users as AX does) - I don't know if the solution for that is to write in C# and not in X++, but I want to know if there any solution in X++, please.

    Thanks :)

  • Suggested answer
    Anton Venter Profile Picture
    20,273 Super User 2025 Season 2 on at
    RE: OdbcConnection object

    Hi Eitan, yes integrated security is the default but you can specify the user name and password on the LoginProperty object. Have look at this blog for an example. Or you can create a connection string specifying the user name and password. There is a .NET class for creating a connection string, it is called the SqlConnectionStringBuilder class.

  • Community Member Profile Picture
    on at
    RE: OdbcConnection object

    I am using a single user to connect the database - I don't want to add any new user to database.

    I always I get message like:

    [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'currentdomain\currentuser', even the current user is not the user who do the login to db.

    It seems that AX enforce me to use the same user as current windows' user (so, the current user shall be in database).

  • Suggested answer
    Anton Venter Profile Picture
    20,273 Super User 2025 Season 2 on at
    RE: OdbcConnection object

    Hi Eitan, is your connection using the current Windows user? With an ODBC connection, you can specify which credentials to use in code, so why don't you use just a single user for connecting to the external database?

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans