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 :
Microsoft Dynamics AX (Archived)

Problem connecting Oracle DataBase from X++

(0) ShareShare
ReportReport
Posted on by

Hello,

I must connect with an external Oracle DataBase from X++ code. Due i am newbie in these questions, I am trying to connect with my own database (Oracle as well (Ax 2009)) before. I can't achieve it.

I tried this:
static void connectOracle_01ADO(Args _args)
{
    #CCADO
    CCADOConnection connection;
    str             connectionString;
    ;
    connectionString    = "Provider=OraOLEDB.Oracle.1;Password=xxx;Persist Security Info=False;User ID=xxx;Data Source=xxxoracle10g";
    connection = new CCADOConnection();
    connection.open(connectionString, #adConnectUnspecified);

    connection.close();
    info("OK");
}
But when it goes to open the connection, it throws an error:
'Method 'open' in COM object of class 'ADODB.Connection' returned error code 0x800A0E7A (<unknown>) which means: Provider cannot be found. It may not be properly installed.'

I tried another way:
static void connectOracle_02OLE(Args _args)
{
    System.Data.OleDb.OleDbConnection connection;
    InteropPermission perm;
    str             connectionString;
    ;
    try
    {
        perm = new InteropPermission(InteropKind::ClrInterop);
        if (perm == null)
        {
            throw error("Error with file permissions");
        }

        perm.assert();
        connectionString    = "Provider=OraOLEDB.Oracle.1;Password=xxx;Persist Security Info=False;User ID=xxx;Data Source=xxxoracle10g";
        connection = new System.Data.OleDb.OleDbConnection(connectionString);
        connection.Open();

        if(connection)
            connection.Close();
        info("OK");
    }
    catch
    {
        error("An Exception has occurred");
    }
}
Again, when it tries to open connection, it fails (doesn't throw any error)

I have created an .udl file (Universal data link files (or '.udl files') provide a common user interface for specifying connection attributes) and it works fine.
This tool allows to get the connection string it has used to connect to data base. In this case it is:
"Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=xxx;Data Source=xxxoracle10g", the same (without password, obviously) as I have used in the jobs.

The last test has been using the 'OracleConnection.dll' (I've imported it in the References AOT node)
static void connectOracle_03OracleConnection(Args _args)
{
    System.Data.OracleClient.OracleConnection   connection;
    InteropPermission                           perm;
    str                                         connectionString;
    ;
    try
    {
        perm = new InteropPermission(InteropKind::ClrInterop);
        if (perm == null)
        {
            throw error("Error with file permissions");
        }

        connectionString    = "Server= xxxOracle10g; User ID=xxxx;Password=xxxx";
        connection = new System.Data.OracleClient.OracleConnection(connectionString);
        connection.Open();

        if(connection)
            connection.Close();
        info("OK");
    }
    catch
    {
        error("An Exception has occurred");
    }
}
Again the same when it tries to open connection, it fails (doesn't throw any error)

I'm getting mad...

Any suggestion?.
Thanks in advance.

Carlos

*This post is locked for comments

I have the same question (0)
  • Denis Macchinetti Profile Picture
    16,444 on at

    Hi Carlos

    May be the problem could be the keywords "Integrated Security=Yes" for manage a Trusted Connection.

    Try to check also the string connection at this link www.connectionstrings.com

    Denis Macchinetti

    MCITP in Developer for AX 2009

    http://sinedax.blogspot.com/

  • Community Member Profile Picture
    on at

    Dennis, thanks a lot and sorry for my late response.

    I've been on a client last week and now a colleague has taken the Oracle connection development :-(

     Anyway, I will check the link you provided. Sure it's really interesting.

    Thanks again and best regards.

    Carlos

  • Dick_Bao Profile Picture
    5 on at

    Hi Carlos

    Could you tell me your methor of resove this question ,Now , I have a question the same to you ,thanks

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans