+ Start a Discussion
Keaton KleinKeaton Klein 

Soql query error

I have a C# program what was working great until i modified this query.  The query currently reads...

qr1 = binding.queryAll("select id, external_id__c from contact where external_id__C in '" + naidno2 + "'");

This line of code produces this error message... "Binding variable only allowed in Apex code"

naidno2 is a string which contains unique IDs separated by commas, i.e. "A4568,R4568,D6548,A4568"
 
Best Answer chosen by Keaton Klein
Shaijan ThomasShaijan Thomas
Hi Klein,

Please try to send the data in following format;

string s1='Test';
string s2='Test 1';
string Querystring = 'select Id, Name from Account where name in (\''+s1+'\''+','+'\''+s2+'\')';
Input query string should be like this ==>select Id, Name from Account where name in ('Test','Test 1')

Thanks
Shaijan

All Answers

Shaijan ThomasShaijan Thomas
Hi Klein,

Please try to send the data in following format;

string s1='Test';
string s2='Test 1';
string Querystring = 'select Id, Name from Account where name in (\''+s1+'\''+','+'\''+s2+'\')';
Input query string should be like this ==>select Id, Name from Account where name in ('Test','Test 1')

Thanks
Shaijan
This was selected as the best answer
Keaton KleinKeaton Klein
Sorry i forgot to reply but I was able to get this working using Shaijan's suggestion.