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