DynamicsNAV web service , RealMultiple and DataSet

stomar_3stomar_3 Member Posts: 26
edited 2009-10-30 in NAV Three Tier
Dear frends,

I face one issue regarding consuming DynamicsNAV services for which do not know ansewr.
Namely, I want to make one web service which use standard DynamicsNAV services to read data and than with Data Set to return that data.

This is web service should to pickup data about all Customers which Location Code is RED and then to return that in Data Set.
But my output here is empty.
Can somebody tell me where is problem with this code and why data set is empty.

Thanks in advance.


[WebMethod]
public DataSet ReadNAVCustomers()
{
Customer.Customer_Service service = new Customer.Customer_Service();

service.Url = "http://localhost:7047/DynamicsNAV/ws/CRONUS_International_Ltd/Page/Customer";
service.UseDefaultCredentials = true;

Customer.Customer_Filter filter = new Customer.Customer_Filter();
filter.Field = Customer.Customer_Fields.Location_Code;
filter.Criteria = "RED";

Customer.Customer[] customers = service.ReadMultiple(new Customer.Customer_Filter[] {filter},null,0);

DataSet ds = new DataSet();
DataRow dr;
DataTable dt = ds.Tables.Add("Customer");



DataColumn dc = new DataColumn("VALUE", Type.GetType("System.String"));
dt.Columns.Add(dc);


foreach (Customer.Customer Customer1 in customers)
{
dr = dt.NewRow();
dr["VALUE"] = Customer1.Name.ToString();
}


return ds;

}

}

Comments

  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    I don't know if you already found out - but I think you need an insert of the row

    foreach (Customer.Customer Customer1 in customers)
    {
    dr = dt.NewRow();
    dr["VALUE"] = Customer1.Name.ToString();
    dt.Insert(dr); - or something like this (I use this in my Edit In Excel sample - which you can find on my blog)
    }
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • stomar_3stomar_3 Member Posts: 26
    Thanks,

    Didn't find solution yet, but will try this what you wrote and than will notify you.
  • stomar_3stomar_3 Member Posts: 26
    freddy.dk wrote:
    I don't know if you already found out - but I think you need an insert of the row

    foreach (Customer.Customer Customer1 in customers)
    {
    dr = dt.NewRow();
    dr["VALUE"] = Customer1.Name.ToString();
    dt.Insert(dr); - or something like this (I use this in my Edit In Excel sample - which you can find on my blog)
    }

    Hi I have found a solution :

    Must add this instead to add dt.Insert , thanks on your help.

    dt.Rows.Add(row);
    dt.AcceptChanges();
Sign In or Register to comment.