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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

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

(0) ShareShare
ReportReport
Posted on by 470

im trying to connect to a database using odbc in x++. im always getting error that the operation failed. i double checked the server name and the database name and it still wont connect. any thoughts would be appreciated. thanks!

heres a part of my code:

 

OdbcConnection connection; 

LoginProperty loginProp;

;


loginProp = new LoginProperty();

    loginProp.setServer("[insert server name here]");

    loginProp.setDatabase("[insert database name here]");

    try

    {

        connection = new OdbcConnection(loginProp);

    }

    catch

    {

        error ("You do not have access to the database specified");

        return;

    }

*This post is locked for comments

  • Verified answer
    jr macarilay Profile Picture
    470 on at

    solved it. i created a system dsn with the ax database as my default database then i modified my code.

    i removed loginProp.setServer and loginProp.setDatabase and replaced it with loginProp.setDSN("[insert DSN name here]")

    worked for me.

  • DAXWAR Profile Picture
    20 on at

    Hi Macarilay ,

    Hope you are good.

    I am facing the very same error "ODBC operation failed.\nUnable to log on to the database.".

    I tried with the suggested code change  but could not fix it.

    logInProperty.setDSN(systemInfo.getloginDSN());

    Value is returning in this is null.

    It would be great if you could help on this.

    Regrds,

    DAX

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Prashant Singh Profile Picture

Prashant Singh 2

#1
nmaenpaa Profile Picture

nmaenpaa 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans