Vasanth Arivali's Blog

Connect External Data Base in Dynamics Ax 2009

Posted on: October 27, 2010

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();

}

}

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

Welcome

What’s happening?

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Categories

Join 13 other followers

%d bloggers like this: