Hi. I’m looking for a solution about this case.
OLE DB component is used for batch class to connect with oracle database and it has changed as ‘called from’/‘server’/‘client’, but it doesn’t work properly. I have already changed ‘server static’ instead of ‘public’ and property of class was changed, too(‘called from’ → ‘server’). I think that AX2009 batch class doesn’t support .net component. Right?
Please let me know about this problem.
Code is like this.
public void SelectQuerySample(KICKR_IFTarget _IFTarget = KICKR_IFTarget::KISDB)
{
System.Exception e;
System.Data.OleDb.OleDbConnection objConn;
System.Data.OleDb.OleDbCommand cmdSelect;
System.Data.OleDb.OleDbDataReader reader;
InteropPermission perm;
str exceptionStr;
str ConnectionString;
str sSQL;
KICKR_Test KICKR_Test;
int iCnt, i;
str dd;
perm = new InteropPermission(InteropKind::ClrInterop);
perm.assert();
try {
ConnectionString = strfmt(“Provider=OraOLEDB.Oracle.1;Persist Security info =false;Data Source=%1;User ID=%2;Password=%3”,oracl_backup,test1,test1);
objConn = new System.Data.OleDb.OleDbConnection(ConnectionString);
objConn.Open();
cmdSelect = objConn.CreateCommand();
//Job range →
sSQL = "SELECT AAA ";
sSQL += " FROM ta_item_pic where rownum < 100 ";
cmdSelect.set_CommandText(sSQL);
reader = cmdSelect.ExecuteReader();
while (reader.Read())
{
KICKR_Test.ItemId = reader.get_Item(‘AAA’);
KICKR_Test.insert();
}
//Job range ←
objConn.Close();
}
catch(Exception::CLRError)
{
CodeAccessPermission::revertAssert();
perm = new InteropPermission(InteropKind::ClrInterop);
if (perm == null)
{
return;
}
perm.assert();
e = ClrInterop::getLastException();
CodeAccessPermission::revertAssert();
while( e )
{
exceptionStr += e.get_Message();
e = e.get_InnerException();
}
info(exceptionStr);
} catch {
throw error(“An Exception has occurred”);
}
CodeAccessPermission::revertAssert();
}