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)
Connect and upload in azure blob with azure key vault using x++
Today, I will be sharing details about file upload in azure blob using azure vault that includes pre requisite and code snippet used to it....
-
Today, I will discussing about how to create a batch job using SysOperationFramework in Dynamics 365 Finance And Operations. Let's sup...
-
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 be discussing about one of the common issue related to query creation using query build data source. Let's suppose we ...
No comments:
Post a Comment
Note: only a member of this blog may post a comment.