Dynamics Axapta Coverage and help materials or tutorials for developer using language x++: Connecting to External Database From Axapta by x++ code

Pages

Addthis Sharing Gadget

Thursday, February 23, 2012

Connecting to External Database From Axapta by x++ code

  Connecting to External Database From Axapta by x++ code.Following code works fine. I tried it.

   CCADOConnection connection;
    CCADOCommand    Cmd;
    CCADORecordSet  RS;
    CCADOFields     fields;
    Com             Coms;
    Str             Sql;
    Str             Provider    = "testServer";
    Str             DataBase    = "Testdb";
    Str             UserId      = "abc";
    Str             PWD         = "xyz";
    Str             ConnStr = strfmt("Provider=SqlOledb;server=" +
Provider + ";trusted_Connection=false;" +
                                        "Initial catalog=" + DataBase +
";user id=" + userid + ";password='" + PWD + "';");

    ;
    Sql = "Select * from InventTable where itemid="10001"";

    connection = new CCADOConnection();
    connection.open(ConnStr);

    Cmd = new CCADOCommand();
    Cmd.activeConnection(connection);
    Cmd.commandText(sql);

    RS = new CCADORecordSet();
    RS = Cmd.execute();
    Coms = RS.recordSet();

    while (!RS.EOF())
    {
        fields = RS.fields();
        info(strfmt("%1", fields.itemIdx(0).value()));

        Coms.moveNext();
    }

    connection.close();
    connection = null;

1 comments:

John Mann said...

I'm the same way I do my best to remain neutral. It's hard if you communicate with the person the other person dislikes then you fall out of favor with them! I simple can't dislike a person just because someone else does I just can't. free cell phone

Post a Comment

Video clips-ERP

Loading...

Follow blog by Email

Daynamics Axapta Coverage

Status of Website

View My Stats
Active Search Results
Wink Bingo | Slots Tips | Football manager 2010 | blackjack free | Poker Stars
Technology Blogs
Technology blog Submitdomainname.com