Today, I will be discussing about how to create an odbc connection in AX. As we all know our system might require data from external resources for instance directly connecting with data base.
For this purpose first you need to configure ODBC connection and use odbcconnection class for creating connection with data base using X++.
Below is the code snippet.
LoginProperty loginProperty;
OdbcConnection odbcConnection;
Statement statement;
str sqlInsert;
SqlStatementExecutePermission permInsert;
// Set the information on the ODBC.
loginProperty = new LoginProperty();
loginProperty.setDSN('DSN Name');
loginProperty.setDatabase('Integration database name');
odbcConnection = new OdbcConnection(loginProperty);
if ( odbcConnection)
{
statement = odbcConnectionInsertHeader.createStatement();
sqlInsert = strFmt('INSERT INTO [table_name]([field1], [field2])') + strFmt('VALUES(values1, value2)')
permInsert = new SqlStatementExecutePermission(sqlInsert);
permInsert.assert();
statement.executeUpdate(sqlInsert);
CodeAccessPermission::revertAssert();
}
statement.close();
Subscribe to:
Post Comments (Atom)
Custom Business events Part 3 - (Activate custom business event) in D365 F&O
In this blog we will discuss about the steps to activate a custom business in D365 F&O. As we know that business event catalog does not...
-
Today, I will share another part of connecting azure blob storage with Dynamics 365 for finance and operations series. This part will be abo...
-
Today I will be discussing about how to create batch job through x++. Before going in code lets discuss what are batch jobs. Batch job : ...
-
Today, I will discussing about how to create a batch job using SysOperationFramework in Dynamics 365 Finance And Operations. Let's sup...
No comments:
Post a Comment
Note: only a member of this blog may post a comment.