It is possible to call a SQL Server Stored Procedure using X++ code.
First you have to create a stored procedure in AX database.Then use the X++ code stated below wherever necessary.
static void callingsp(Args _args)
{
LoginProperty loginProperty;
OdbcConnection odbcConnection;
Statement statement;
ResultSet resultSet;
;
loginProperty=new LoginProperty();
loginProperty.setServer("serverName");
loginProperty.setDatabase("dbname");
try
{
odbcConnection=new OdbcConnection("loginProperty");
catch
{
return;
}
}
statement=myConnection.createStatement();
resultSet=statement.executeQuery('EXEC[spname]'); //stored procedure name
while(resultSet.Next())
{
print resultSet.getString(1);
}
pause;
}
Siva
ho w we can pass parameters to storedprocedure???
ReplyDelete