blog for Dynamics Axapta

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: