Using DotNet DataTable in C/AL

viperkviperk Member Posts: 12
edited 2011-03-24 in NAV Three Tier
Hi,

I'm trying to send a datatable from a C# app. to a codeunit in NAV.
My problem is that i can't figure out how to use the Rows property on my datatable.
I would like to select a specific column by using this syntax (in C/AL)

myCALVariable := myDataTableFromDotNet.Rows.ToString();

but when i compile i get a compilation error saying that the Rows variabel is defined with fewer dimensions. Is there a way around this or shouldn't i use datatables from dotnet in my c/al code?

thanks in advance

Comments

  • ara3nara3n Member Posts: 9,256
    One thing I've seen is that methods that are overloaded, they appear as separate lines when you hit F5. And you select the one with correct parameters.
    You might have selected the wrong one. Or probably just pasted your code? I would try that.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • viperkviperk Member Posts: 12
    The exception comes from the property "Rows" not a method.
    And there is only one "Rows" property to choose. This property returns a collection, but when using it in C# i can also call it with an index (Rows[x]) to retrieve a specific column.
    But i don't seem to be able to use this index in C/AL.
  • smalkmussmalkmus Member Posts: 18
    This may not be much help but we had a similar problem trying to consume .net arrays because we could not access the array index. What we ended up doing was creating a wrapper DLL that adding a methods to return the size of the array and added getObject(int i) and setObject(object o, int i) methods for getting and setting objects. A similar approach might be an option for you if you can't find another way of consuming the data table in C/AL.
  • kinekine Member Posts: 12,562
    Try to search for method ".Value(index)" or ".Item(index)" instead [] operator.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • viperkviperk Member Posts: 12
    thanks a lot! I'll try your suggestions
  • henrikmhenrikm Member, Microsoft Employee Posts: 66
    As suggested by kine you have to use the Item() method, the [] will not work in C/AL.

    /henrik
    “This posting is provided "AS IS" with no warranties, and confers no rights.”

    Henrik Metzger, Software Development Engineer, Dynamics NAV
    MSFT
Sign In or Register to comment.