Wednesday, September 2, 2009

CCADOConnection Tutorial

This tutorial is helpful if you want to update another database from Dynamics AX

 

 

static void CCADO_Tutorial(Args _args)

{

    CCADOConnection     conn;

    CCADORecordSet      rst;

    CCADOCommand        cmd;

    str                 connStr, sqlStr;

    ;

 

    conn = new CCADOConnection();

    cmd = new CCADOCommand();

   

    connStr = strFmt('Provider=SQLOLEDB.1;Persist Security Info=False;User ID=%1;Password=%2;Initial Catalog=%3;Data Source=%4'

            , 'sa'  //username

            , ''  //pwd

            , 'TestDB'  //database

            , 'TESTSERVER' //server

            );

 

    conn.open(connStr);

 

    cmd.activeConnection(conn);

 

    sqlStr = "UPDATE EMPLTABLE SET EMPLID = N'NewEmplId' WHERE (EMPLID = N'OldEmplId')";

 

    cmd.commandText(sqlStr);

    cmd.execute();

 

}

No comments:

Post a Comment