f we need to interface any external database with Dynamics AX, we can achieve this task by using ADO and its AX available classes:CCADOConnection, CCADORecordSet, CCADOFields, CCADOField andCCADOCommand. Here an example:
If we need to execute something (an UPDATE, DELETE, etc.), we can use the CCADOCommand:
NOTE: For working with ADO constants like cursor types (adOpenForwardOnly, adOpenKeyset, adOpenDynamic, adOpenStatic), we only need to include the macro CCADO (#CCADO) where they are defined.
static void ADOTestJob(Args _args)
{CCADOConnection ccConnection;CCADOCommand ccCommand;
CCADORecordSet ccRecordset;
CCADOFields ccFields;
str st;
str data1;
int data2;;
ccConnection = new CCADOConnection();// Setting the connection string
ccConnection.connectionString(StrFmt('Provider=SQLOLEDB.1;Persist Security Info=False;User ID=%3;Password=%4;Initial Catalog=%2;Data Source=%1', 'servername' // Server's IP or name,
'database' // Database or catalog,
'user' // Username,
'pwd' // Password));// Open the connection
ccConnection.open();// Preparing the queryst = "SELECT * FROM mytable";// Recordset object creation
ccRecordset = new CCADORecordSet();// Executing the querycc
Recordset.open( st, ccConnection );// Reading datawhile (!ccRecordset.EOF()){ccFields = ccRecordset.fields();// We can access fields either by name or by Indexdata1 = ccFields.itemName("FIELD1").value();
data2 = ccFields.itemIdx(1).value();info(strfmt("Data %1, %2", data1, data2));// Read next record
ccRecordset.moveNext();
}// Closing the connectionccRecordset.close();
ccConnection.close();}
If we need to execute something (an UPDATE, DELETE, etc.), we can use the CCADOCommand:
void ExecuteSQLExt(str sql){// Creating the ADO Command objectccCommand = new CCADOCommand();// Associate it with an existing opened connectionccCommand.activeConnection(ccConnection);// Executing the commandccCommand.commandText(SQL);ccCommand.execute();}
NOTE: For working with ADO constants like cursor types (adOpenForwardOnly, adOpenKeyset, adOpenDynamic, adOpenStatic), we only need to include the macro CCADO (#CCADO) where they are defined.
06:41:53 am . 03 Jan 2009
soccer jersey wholesale
Replica Roado Watches
Replica Watches
Replica Handbags
Replica Watches
four color printing
Replica Panerai Watches
Replica Breitling Watches
Replica Swiss Watches
Replica Prada Wholesale
four color printing
Replica Breitling Watches
Fake Watches
Notebook Printing
Magazine Printing
Fake Handbas
Fake Watches
Replica Bag Wholesale
Fashion watches