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 :
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,363 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,225 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 694

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 646 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 337

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans