web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

ODBC Connection for writing data

Pooja Karki Profile Picture Pooja Karki 3,045
Today I will demonstrate you that how to establish ODBC connection and use that for writing data in AX.

static void WriteOdbc(Args _args) 
{
OdbcConnection connection;
LoginProperty loginProp;
Statement statement;
str sqlStmt;
SqlStatementExecutePermission permission;
;
loginProp = new LoginProperty();
loginProp.setServer("SEA-DEV");
loginProp.setDatabase("MicrosoftDynamicsAX");
try
{
connection = new OdbcConnection(loginProp);
}
catch
{
error ("You do not have access to the database specified");
return;
}
sqlStmt = strfmt("UPDATE dbo.CustTable SET Name='test' WHERE AccountNum='%1' AND Dataareaid='%2'", "1101", "ceu");
permission = new SqlStatementExecutePermission(sqlStmt);
permission.assert();
statement = connection.createStatement();
statement.executeUpdate(sqlStmt);
CodeAccessPermission::revertAssert();
}

This was originally posted here.

Comments

*This post is locked for comments