+ Start a Discussion
vino1.395228003587918E12vino1.395228003587918E12 

Bind variables only allowed in Apex code error in SOQL query from .Net

Hi,
I have fetched the AsyncApexJob from .Net.
In SOQL i got the "Bind variables only allowed in Apex code" Error.

My code is:

string res = "Failed";
            QueryResult query = null;
            string soql;
            soql = "SELECT Status,JobType,NumberOfErrors,CompletedDate FROM AsyncApexJob WHERE Status="+res+"";
            query = sfdcbind.query(soql);

Anyone help to solve this.
SuperfellSuperfell
You need to put quotes around the literal value, e.g.
soql = "SELECT Status,JobType,NumberOfErrors,CompletedDate FROM AsyncApexJob WHERE Status='"+res+"'";
vino1.395228003587918E12vino1.395228003587918E12
No i got the same error.....
"System.Web.Services.Protocols.SoapException: MALFORMED_QUERY:
CompletedDate FROM AsyncApexJob Status='Completed' "
sudeep ksudeep k
I got the same error

where Build_To_Account__c != Ship_To_Account__c ^ ERROR at Row:1:Column:152 Bind variables only allowed in Apex code

when I ran a query from Developer console:query Editor:

 select id , Build_To_Account__c,Build_To_Account__r.Id,Ship_To_Account__c, Ship_To_Account__r.Id  from  Sales_History__c   where Build_To_Account__c != Ship_To_Account__c
Ali Jaffar 10Ali Jaffar 10
I've run into the same problem. I plan to first retrieve the data from the first SOQL query then loop through each row and assign an updated value to one of the fields -- which I tried a subquery for. It's not possible with the JSForce library in an external location to bind variables..this is likely a security limitation.