Retrieve record from multiple table through Business Connector


Today I will demonstrate you that how to retrieve record from multiple table through Business Connector in AX.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Dynamics.BusinessConnectorNet;
namespace testing
{
class Program
{
static void Main(string[] args)
{
try
{
Axapta ax = new Axapta();
ax.Logon("Cee", null, null, null);
AxaptaRecord ar = ax.CreateAxaptaRecord("EmpPersonal"), axr = ax.CreateAxaptaRecord("EmpRecord");
ax.ExecuteStmt("select * from %1 join %2 where %1.EmpId==%2.EmpId", ar, axr);
while (ar.Found)
{
Console.WriteLine("Empid: {0} EmpSal: {1}", ar.get_Field("EmpId"), axr.get_Field("EmpSal"));
ar.Next();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
}
}

Note:- Write above code in Visual Studio CUI application and add reference of "Microsoft.Dynamics.BusinessConnectorNet.dll" file in CUI project. 

Comments