Skip to main content

Notifications

Announcements

No record found.

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

  • DAXWAR Profile Picture
    DAXWAR 20 on at
    RE: ODBC operation failed. Unable to log on to the database.

    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

  • Verified answer
    jr macarilay Profile Picture
    jr macarilay 470 on at
    Re: ODBC operation failed. Unable to log on to the database.

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans