AX2012 replacement for CCAdoConnection class.

Hi ,

In AX2009 We have CCADOConnection class which we can use to connect to database.

code is as follows.

CCADOConnection connection = new CCADOConnection();

CCADOCommand ccADOCommand;

CCADORecordSet record;

try

{

connection.open(connectStr);

ccADOCommand = new CCADOCommand();

strQuery=“SELECT DB_NAME(database_id) AS DatabaseName,Name AS Logical_Name,Physical_Name, (size*8)/1024 SizeMB FROM sys.master_files WHERE DB_NAME(database_id) = '”+ sysSQLSystemInfo::construct().getloginDatabase() +"’" ;

ccADOCommand.commandText(strQuery);

ccADOCommand.activeConnection(connection);

record = ccADOCommand.execute();

recordSet = record.recordSet();

while (!record.EOF())

{

i+=record.fields().itemIdx(3).value();

recordSet.moveNext();

}

result = int2str(i)+“MB” ;

}

In AX2012 we dont have ccado connection class.Does anybody knows replacement for that CCADOConnection class?

Thanks in Advance.

Sunny

We don’t have ccdao connection class in AX2012 so i tried using following to connect to external database.

and it worked for me.

code is as follows:

LoginProperty loginProp;

ODBCConnection conn;

Resultset resultSet, resultSetCount; // get record

Statement statement1, statement2; // Create SQL Statement

ResultSetMetaData metaData ; // get Record metadate like columnname.

container c;

int result=0;

int i;

;

// Set Server Database

loginProp = new LoginProperty();

loginProp.setServer(‘servername’);

loginProp.setDatabase(‘databse name’);

// Create Connection and SQL Statement

conn = new ODBCConnection(loginProp);

statement1 = conn.createStatement();

resultSet = statement1.executeQuery(“SQLquery”);

while (resultSet.next())

{

metaData = resultSet.getMetaData();

c=conIns(c,1,resultSet.getString(4));

//info(" DBName ="+resultSet.getString(1)+“Name=”+resultSet.getString(2)+“size=”+resultSet.getString(4));

}

for (i = 1 ; i <= conlen(c) ; i++)

{

//info(strFmt(’%1’, conpeek(c, i)));

result+=conpeek(c, i);

}

info(strFmt(’%1’,result));