0
listAccount=database.query('select id,name,BillingState,Phone,Website from Account where name Like '+searchString);

getting searchString value from vf page Having Following error:

expecting a colon, found 'sForce'

Error is in expression '{!displayAccounts}' in component in page interviewtwo: Class.InterviewTwo_Controller.displayAccounts: line 14, column 1

An unexpected error has occurred. Your development organization has been notified.

5

You need to include a string in quotes, or, even better, simply use a bind variable, which reduces the odds of SOQL injection:

listAccount = Database.query('select name, billingstate, phone, website '+
                             'from account where name like :searchString');

Generally speaking, though, a query like this can be inlined, since you don't have any dynamic query stuff going on:

listAccount = [select name, billingstate, phone, website
              from account where name like :searchString];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.