I am sending data from AX 2012 R3 CU10 to ODBC. I get a critical error when calling ODBC however, SQL is still updated. Not sure what could be causing the issue. Please find the code below and error message.
server public static void runOdbcQuery(str _OdbcQuery)
{
LoginProperty loginProperty;
OdbcConnection odbcConnection;
Statement statement;
ResultSet resultSet;
SqlStatementExecutePermission perm;
str connection;
BSKParameters odbc;
// Set the information on the ODBC.
select * from odbc;
loginProperty = new LoginProperty();
connection = "Driver=" + odbc.Driver +";Description="+ odbc.Description +";Server=" + odbc.Server + ";Database="+ odbc.Database + ";UID=" + odbc.UserId + ";PWD=" + odbc.Password + ";";
//connection = "Driver=ODBC Driver 11 for SQL Server;Description=OMS_32;Server=" + odbc.Server + ";Database="+ odbc.Database + ";UID=" + odbc.UserId + ";PWD=" + odbc.Password + ";";
loginProperty.setOther(connection);
// Create a connection to external database.
try
{
odbcConnection = new OdbcConnection(loginProperty);
}
catch
{
throw error("Error creating the ODBC Connection");
}
if (odbcConnection)
{
//Prepare the SQL statement.
statement = odbcConnection.createStatement();
perm = new SqlStatementExecutePermission(_OdbcQuery);
perm.assert();
resultSet = statement.executeQuery(_OdbcQuery);
//resultSet = statement.executeUpdate(sql);
}
resultSet.next();
resultSet.close();
statement.close();
}
Error message relates to Invalid Cursor state and from my research it seems as if the Cursor starts before it should. Not sure how to resolve it though. Appreciate any help.