Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

AIF - Return System.Data.DataTable throws Input String was not in a correct format

$
0
0

Hi, I'm trying to consume a service operation from AX in a console C# application, that returns a DataTable, but I keep getting:

Input String was not in a correct format

In the console application.

This is the method in AX:

[SysEntryPointAttribute(true)]
public System.Data.DataTable sendSalesOrderInfo()
{
	SalesTable salesTable = SalesTable::find("001");
	System.String salesId, accountNum, salesName;
	System.Data.DataTable dt = new System.Data.DataTable();
	System.Data.DataColumnCollection columns = dt.get_Columns();
	System.Data.DataRowCollection rows = dt.get_Rows();
	System.Data.DataColumn salesIdColumn, custAccountColumn, salesNameColumn;
	System.Data.DataRow dataRow; 
	
	salesIdColumn = new System.Data.DataColumn("SalesId", System.Type::GetType("System.String"));
	custAccountColumn = new System.Data.DataColumn("CustAccount", System.Type::GetType("System.String"));
	salesNameColumn = new System.Data.DataColumn("SalesName", System.Type::GetType("System.String"));
	
	columns.Add(salesIdColumn);
	columns.Add(custAccountColumn);
	columns.Add(salesNameColumn);
	
	dataRow = dt.NewRow();
	
	salesId = System.Convert::ToString(salesTable.SalesId);
	accountNum = System.Convert::ToString(salesTable.CustAccount);
	salesName = System.Convert::ToString(salesTable.SalesName);
	
	dataRow.set_Item("SalesId", salesId);
	dataRow.set_Item("CustAccount", accountNum);
	dataRow.set_Item("SalesName", salesName); 
	
	rows.Add(dataRow);
	
	return dt;
}

I would appreciate your help, thanks!


Viewing all articles
Browse latest Browse all 175888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>