Hi,
i have analysed your problem a little bit in more detail (ok, i have tried to.. :-) )
Please check the following:
Got to the properties of your StoredProcedure in SQL Server Management Studio. Check that your AOS-Account has the right to execute the SP. For a new created SP the account should not have these rights..
Also check that your code, which calls the SP, is running on server side.
I have check this with the following code and the following SP. After setting the execute right for the SP everything works.
AX Code:
server static void executeSP()
{
Connection con = new Connection();
Statement stmt = con.createStatement();
ResultSet r;
str sql;
SqlStatementExecutePermission perm;
;
sql = strfmt('EXEC [insertdaxjob]');
perm = new SqlStatementExecutePermission(sql);
perm.assert();
try
{
stmt.executeUpdate(sql);
}
catch (exception::Error)
{
print "An error occured in the query.";
pause;
}
CodeAccessPermission::revertAssert();
}
Stored Procedure:
USE [AX2009Database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[insertdaxjob]
AS
BEGIN
SET NOCOUNT ON;
insert into dbo.TestTable(ID, Name, RECID, RECVERSION, DATAAREAID) values('1', 'Test', 5637144590, 1, 'ceu')
END
As you can see i simple have added the SP to the AX Database. That is the reason for RecId, RecVersion and DataAreaId fields. But this should also work with any other database were the SP is located in.