Hello together,
currently I'm trying to integrate a .NET control into MS Dynamics AX 2012. In order to display the values. The control needs a certain .NET DataSet (System.Data.DataSet) to be passed.
Are there any good examples how I could create a DataSet within x++ and fill it with data?
I found a Job the data could be read from a XML file but unfortunately I don’t get any response:
static void TestDOTNETDataSet(Args _args)
{
System.Data.DataSet DataSet;
System.Data.DataTableCollection DataTableCollection ;
System.Data.DataTable DataTable;
System.Data.DataRowCollection DataRowCollection;
System.Data.DataColumnCollection DataColumnCollection;
System.Data.DataRow DataRow;
System.Data.DataColumn DataColumn;
int i,j,TotalCol,TotalRow;
str _xml;
;
DataSet = new System.Data.DataSet();
DataSet.ReadXml(@"C:\Data.xml", System.Data.XmlReadMode::ReadSchema);
DataTableCollection = DataSet.get_Tables();
DataTable = DataTableCollection.get_Item(0);
DataColumnCollection = DataTable.get_Columns();
DataRowCollection = DataTable.get_Rows();
TotalRow = DataRowCollection.get_Count();
TotalCol = DataColumnCollection.get_Count();
for(i = 0; i < TotalRow; i ++)
{
DataRow = DataRowCollection.get_Item(i);
//setprefix(CLRInterop::getAnyTypeForObject(DataRow.get_Item(i)));
for(j = 0; j < TotalCol; j ++)
{
//DataRow = DataRowCollection.get_Item(i);
if (DataRow.IsNull(j))
_xml = 'null';
else
_xml = DataRow.get_Item(j);
info(strfmt("%1 - %2 - %3",i,j,_XML));
}
}
}
Furthermore this solution would imply, that I have to write the data from AX-Tables into an XML-File, which would be “double work”. I would prefer to create / write the dataset directly in AX.
Any help would be appreciated.
Thanks in advance
Sebastian