Thursday, November 23, 2006

Updating external database using X++

loginProperty loginProperty = new LoginProperty();
ODBCConnection odbcConnection;
Statement sql;
ResultSet result;
;
loginProperty.setDSN('dsnName');
loginProperty.setUsername('');
loginProperty.setPassword('');
odbcConnection = new ODBCConnection(loginProperty);
if (odbcConnection)
{
sql = odbcConnection.createStatement();
result = sql.executeQuery("select * from table");
while (result.next())
{
print result.getString(1);
}

}

3 comments:

  1. When using this code, I get the following error message:

    Cannot execute the required database operation. This function is no longer supported.

    I'm using AX 4.0 sp1

    What can I do about it?

    ReplyDelete
  2. I tried to use this code to connection to a legacy application.

    I got the following error:
    Cannot execute the required database operation. This function is no longer supported.

    I am using AX 4.0 SP1.

    What can I do about it?

    ReplyDelete
  3. Hi,

    Using the ODBC connection to select and update a record requires 2 connections to be established.

    If I try to use a global connection and use it in both the select and update statements, it gives an error "Connection is busy". On further analysis, I found that it is required to enable MARS (Multiple Active Result Sets). But I do not find any syntax, how to enable MARS through ODBC connection from X++.

    Please let me know.

    ReplyDelete