Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.
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

2 Answers 2

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:

http://www.salesforce.com/us/developer/docs/soql_sosl/index_Left.htm

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

http://wiki.developerforce.com/page/Integrating_Force.com_with_Microsoft_.NET

http://code.google.com/p/salesforce-dotnet

share|improve this answer
    
Will this update in sales force as well though? –  TooTiredToDrink Mar 4 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. –  Bachovski Mar 4 at 0:52
1  
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 at 1:14
    
In that case check out these links : code.google.com/p/salesforce-dotnet & wiki.developerforce.com/page/… –  Bachovski Mar 4 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]
[ORDER BY fieldOrderByList ASC | DESC ? NULLS FIRST | LAST ?]
[LIMIT ?]
[FOR VIEW] | [FOR REFERENCE
[OFFSET ?]
[UPDATE VIEWSTAT ?]

For more information about what is available in SOQL, see the documentation: http://www.salesforce.com/us/developer/docs/soql_sosl/

And here's a good overview about moving from SQL to SOQL: http://wiki.developerforce.com/page/From_SQL_to_SOQL

share|improve this answer
    
so whats the right aproach? –  TooTiredToDrink Mar 4 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 at 0:48

Your Answer

 
discard

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.