Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Supplied Method Arguments Are not Valid error when using business connector

(0) ShareShare
ReportReport
Posted on by 925

Hi All, I am new to Business Connector in AX.

I try to display customer Id and customer Name in Console window. I get the error as Supplied Method Arguments Are not Valid .

I am sharing my code , correct me where i am wrong.

Thanks In Advance,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Dynamics.BusinessConnectorNet;
namespace BCClass_Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            Axapta ax;
            AxaptaRecord axRecord,axRecord1;
            String tableName = "CustTable";
            String tableName1 = "DirPartyTable";      
            String sqlStmt = ("Select * from %2 join %1 where %2.RecId == %1.party");
            Object cusid ,  name;
            try
            {
                ax = new Axapta();
                ax.Logon(null, null, null, null);
                axRecord = ax.CreateAxaptaRecord(tableName);                
                axRecord1 = ax.CreateAxaptaRecord(tableName1);                    
                axRecord.ExecuteStmt(sqlStmt);
                while (axRecord.Found)
                {
                   cusid = axRecord.get_Field("AccountNum");                           
                   name = axRecord1.get_Field("Name");
                   Console.WriteLine("CustAccountNum \t CustomerName" );
                   Console.WriteLine(cusid + "\t\t  " +name);
                   axRecord.Next();
                 }
                 Console.ReadKey();

        } 

       catch (Exception e)// I caught error as Supplied Method Arguments Are not Valid
       {
                Console.WriteLine("error" + e);
        }
     }
 }

}

*This post is locked for comments

  • Mea_ Profile Picture
    60,278 on at
    RE: Supplied Method Arguments Are not Valid error when using business connector

    Hi Rusty Ryan,

    Can you post full method's code to see how are you using this statement.

  • ThivaKar Profile Picture
    925 on at
    RE: Supplied Method Arguments Are not Valid error when using business connector

    Hi ievgen, Can you tell me the ans for my above question?

  • ThivaKar Profile Picture
    925 on at
    RE: Supplied Method Arguments Are not Valid error when using business connector

    Yes Absolutely , and as i said changed back to while(axRecord.Found).. inside my loop i have name = axRecord1.get_Field("Name");// This gives me correct customer name bcoz of the sql statement , no need to use both..

    "Select * from %1 join %2 where %1.Party== %2.RecId"

    Right Now i am asking , why this statement won't work ??

    "Select * from %2 join %1 where %2.RecId == %1.party"

  • veera seenivasan Profile Picture
    575 on at
    RE: Supplied Method Arguments Are not Valid error when using business connector

    Hi Rusty,

             Ax record belongs to Custtable. Axrecord1 belongs to Dirpartytable when you are looping in Only Axrecord1 it will not have the table fields of Axrecord .So try to use both

  • ThivaKar Profile Picture
    925 on at
    RE: Supplied Method Arguments Are not Valid error when using business connector

    False Alarm ievgen, Thanks for your support ,, I changed my SQL stmt to

    "Select * from %1 join %2 where %1.Party== %2.RecId" and my changed my while loop back as while(axRecord.Found)  and it works perfectly.

    But if u give me heads up on why this stmt won't work

    "Select * from %2 join %1 where %2.RecId == %1.party"

    will help me .. Thanks in Advance

  • ThivaKar Profile Picture
    925 on at
    RE: Supplied Method Arguments Are not Valid error when using business connector

    I have changed the while loop as while(axRecord1.Found) which is now infinite.. and it brings only the first customer name

  • ThivaKar Profile Picture
    925 on at
    RE: Supplied Method Arguments Are not Valid error when using business connector

    Hi ievgen,

    Thank you for the heads up.. how silly of me, missed that ...

    Thanks again.. :)

    And another quick question, As i said i am trying to print the customer id and customer name , Is my Relation is Correct? Bcoz when i run i getting infinite while loop and im getting the first customer name only .. Pls Advice

  • Verified answer
    Mea_ Profile Picture
    60,278 on at
    RE: Supplied Method Arguments Are not Valid error when using business connector

    Hi Rusty Ryan,

    Please look at ExecuteStmt function description msdn.microsoft.com/.../microsoft.dynamics.businessconnectornet.axapta.executestmt.aspx you should pass record as second parameter as well.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,002 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,852 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans