Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
String queryString = "UPDATE Comments__c " +
                             "SET Comments__c = Comments__c + '" + ssComment + "'" +
                             "FROM ts2__Application__c " +
                             "WHERE ts2__Job__c = '" + ssSearchesId + "' AND  ts2__Client__c = '" + ssContactId + "'";

I am on confused why this is not working?

I am looking to update the DB in salesforce as well.

share|improve this question
up vote 3 down vote accepted

Try the following:

String queryString = 'SELECT Id FROM ts2__Application__c WHERE ts2__Job__c = ' + ssSearchesId + ' AND ts2__Client__c = ' + ssContactId + ' LIMIT 1';
List <ts2__Application__c> ts2Applications = Database.query(queryString);

if (ts2Applications.size() > 0)
    ts2__Application__c ts2Application = ts2Applications[0];
    ts2Application.Comments__c = ssComment;
    update ts2Application;

SOQL works differently than classic SQL. Please refer to the following guide:

EDIT: Upon noticing the C# tag, here are some links on .net integration with salesforce:

share|improve this answer
Will this update in sales force as well though? – TooTiredToDrink Mar 4 '14 at 0:51
Yes, update ts2Application; is the DML statement that will do that. Please read the documentation, you will understand better how all this works. – Boris Bachovski Mar 4 '14 at 0:52
well, the question is about c# and this answer is in apex. from c# you would use the update(Sobject [] o) call on the Client object (assuming you're using the SOAP/WSDL api) – superfell Mar 4 '14 at 1:14
In that case check out these links : &… – Boris Bachovski Mar 4 '14 at 1:19

UPDATE and SET are not viable syntax in SOQL. See this reference from the SOQL documentation:

SELECT fieldList  
[TYPEOF typeOfField whenExpression elseExpression END]
FROM objectType
[WHERE conditionExpression]
[WITH [DATA CATEGORY] filteringExpression]
[GROUP BY fieldGroupByList] | [GROUP BY ROLLUP|CUBE (fieldSubtotalGroupByList)]
[HAVING havingConditionExpression]

For more information about what is available in SOQL, see the documentation:

And here's a good overview about moving from SQL to SOQL:

share|improve this answer
so whats the right aproach? – TooTiredToDrink Mar 4 '14 at 0:45
You can't perform actions like setting a object field value within SOQL, it's a pure query. The approach is to use a SELECT to query your objects, then loop through them to set values. – greenstork Mar 4 '14 at 0:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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