function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ygutierrezygutierrez 

Query Error - Unexpected token

(.NET ASP C# 1.1) I get the following error when using the quote symbol ' in the WHERE clause
 

Error: Query Company by name: MALFORMED_QUERY:

from Lead where Company = 'D.G.O'Dell, Inc.'

ERROR at Row:1:Column:44

unexpected token: Dell

I've tried to replace ' with \' before I build the query but I keep getting the same error. The replace doesn't work.

Please let me know if you already solved this problem. I keep googling this but I cannot find anything. I think it should be very simple.

Thanks,

Yesenia

sara .netsara .net

Replacing ' with \' should solve your problem. Please recheck your Query.

If your intial Query is Select Name from Lead where Company = 'D.G.O'Dell, Inc.' then your Query should look like Select Name from Lead where Company = 'D.G.O\'Dell, Inc.'

 

ygutierrezygutierrez
Thanks, I made a silly mistake when using the string replace option.
 
I was using string sTempCompany = sCompany.Replace("'", "\'");

I changed it to string sTempCompany = sCompany.Replace("'", \\');

Now everything is ok. When I test this line I see the right result: select id from Lead where Company = 'D.G.O\'Dell, Inc.'