No overload for method 'query' takes 5 arg

2019-03-05 07:02发布

问题:

I am connecting with salesforce api, I have imported Salesforce enterprise Wsdl to my project.

I can authenticate user but I am having Problem while querying records, I'm not sure what else I am missing and how to solve this

No overload for method 'query' takes 5 arguments

//create SOQL query statement
string query = "SELECT Name, AccountNumber, BillingState FROM Account WHERE BillingState = 'CA'";

enterprise.QueryResult result = queryClient.query(
                header, //sessionheader
                null, //queryoptions
                null, //mruheader
                null, //packageversion
                query);

//cast query results
IEnumerable<enterprise.Account> accountList = result.records.Cast<enterprise.Account>();

//show results
foreach (var account in accountList)
{
      Console.WriteLine(string.Format("Account Name: {0}", account.Name));
}

回答1:

This error is due to difference in number of parameters pass in definition of method and calling. You have passed 5 parameters to the query method and in definition may be different parameters count. Check the query method parameters count and then pass correct count of parameters when calling.



回答2:

You are trying to pass to much parameters to the method.

Hover on the method, press F12 and look at the number of arguments the method expects, Then solve your problem accordingly.



标签: c# salesforce