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;
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:
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