mercredi 14 mars 2012

Connect External Database with Ax 2009


This is the example to connect the External Database to Ax
void ODBCConnection()
{
LoginProperty LP                =  new LoginProperty();
OdbcConnection                  myConnection;
TableName                            TableName;
Statement                              myStatement;
ResultSet                                 myResult;
#define.Constring(“DSN=DSNNAME;UID=USERID;PWD=PASSWORD”)
try
{
LP.setOther(#Constring);
myConnection = new OdbcConnection(LP);
}
catch
{
info(“Check username/password.”);
return;
}
myStatement = myConnection.createStatement();
new SqlStatementExecutePermission(“SELECT * from TableNamewhere bImportflag = 0″).assert();
myResult = myStatement.executeQuery(“SELECT * from TableNamewhere bImportflag = 0″);
CodeAccessPermission::revertAssert();
while (myResult.next())
{
TableName.nMember                = Member;
TableName.tMemberName            = MembName;
TableName.tMemberAddress         = Address;
TableName.tRescountry            = Country;
TableName.tResState              = State;
TableName.insert();
}
}
Thank & Regards
Vasanth Arivali

Aucun commentaire:

Enregistrer un commentaire