ODBC error - AX 2009

Hi,

I have a table in another database. I wrote the codes to open the ODBC connection and the particular table.everything is fine.

There are 3 records in this table.

I can view them in the Info log also.

In my AOT, i have created a similar Table. When I run the code,it inserts, the 1st record successfully. Then it gives error

“Cannot execute the required operation, The operation failed”

[Microsoft][SQL Native Client]Invalid Descriptor Index

Any idea what could be wrong…

Here is my code.

public server static void GetHeader()
{

ODBCConnection conn;
LoginProperty loginprop;

Resultset resultSet; //Result of excecution
Statement myStatement;
SqlStatementExecutePermission perm;
str sql_Header;
int i;

MenaAxJournalHeader menaAxJournalHeader;
;

sql_Header = strfmt(‘select * from MenaAxInterimHeader where valid = 1’); //Sentence to execute in SQLServer-database

//Get ODBC connection
loginprop = new loginproperty();
loginprop.setServer(‘ERP-SERVER’); //Variables to connection
loginprop.setDatabase(‘MenaAXInterimDB’); //Variables to connection

//Create a connection to external database
try
{
conn = new ODBCConnection(loginprop);
}
catch
{
throw error(“Error creating ODBC connection”);
}
// Execute the sentence
if(conn)
{
if(sql_Header == “”)
{
throw error(“No sql statement to execute”);
}
//Assert permission for executing the sql string
perm = new SqlStatementExecutePermission(sql_Header);
//Check for permission to use the statement
perm.assert();
perm.owner();

//Prepare the sql statement
myStatement = conn.createStatement();
resultset = myStatement.executeQuery(sql_Header);
}

i = 0;
while (resultSet.next())
{
MenaAxJournalHeader.JounrnalNum = resultSet.getString(1);
MenaAxJournalHeader.JournalDate = resultSet.getDate(2);
MenaAxJournalHeader.JournalDesc = resultSet.getString(3);
MenaAxJournalHeader.Valid = resultSet.getInt64(4);

MenaAxJournalHeader.insert();

}

//close the connection
if (resultset)
{
resultset.close();
}
if(mystatement)
{
mystatement.close();
}

//End the scope of assert statement
codeaccesspermission::revertAssert();
}

Please consider this as CLOSED.

It was a minor mistake from my side

(::

Hi ,

Thanks for this post. What is that minor issue had done? Is that was the problem with your code or due to any persission or set up problem???

Regards,

Enrique