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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Getting error while establishing ODBC connection in AX2012

(0) ShareShare
ReportReport
Posted on by 758

Hi, 

Need urgent help.

I am using below code for establishing ODBC connection but getting error as

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

Please help.

static void SITestODBC(Args _args)
{
    OdbcConnection           oDBCConnection;
    LoginProperty            loginProperty;
    str                      connectionString;


    try
    {
        connectionString = "DSN=RFIDDB_UAT;Database=myTest_db;UID=sa;PWD=$1234;";

        loginProperty = new LoginProperty();
        loginProperty.setOther(connectionString);
        oDBCConnection = new ODBCConnection(loginProperty);
        if(oDBCConnection)
        {
            info("success");
        }
    }
    catch
    {
        throw error("@CHI814");
    }

}

I have the same question (0)
  • Verified answer
    WillWU Profile Picture
    22,361 on at

    Hi Rhushikesh Raut,

    How did you create your DSN?

    You don't need to put the username and password in your connection string.

    pastedimage1605076560162v1.png

    Try the following code:

    loginProperty = new LoginProperty();
    loginProperty.setDSN("dsnName");
    loginProperty.setDatabase("databaseName");
    odbcConnection = new OdbcConnection(loginProperty);

    Refer to:docs.microsoft.com/.../how-to-connect-to-an-external-database-from-x-code

  • Rhushikesh R Profile Picture
    758 on at

    Hi Will, I will test the connection directly from Administrative tools first and will update you. It might be the case that the credentials have been changed as before this error I was able establish connection with same code.

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Rhiushikesh,

    Please check if any permissions have been changed on the external database as well. That could also cause this issue.

  • Suggested answer
    A.Prasanna Profile Picture
    8,223 on at

    also maks sure you are allow required Ports through firewall(s)

    1433 (ODBC)

    netbios (UDP ports 137, 138 & TCP 139 for NetBIOS over TCP)

    Regards,

    Amith Prasanna

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans