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

Update Account Sample not working

I have just started using SalesForce and am having trouble getting the update Account Sample to work.

//create the account object to hold our changes

sforce.sObject updateAccount = new sforce.sObject();

//need to have the id so that API knows which account to update

//set a new value for the name property

updateAccount.Id = "0016000000hkyAAN";

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

System.Xml.XmlElement nameElement = doc.Xml.XmlElement("Name");


nameElement.InnerText = "New Account Name from Update Sample";

updateAccount.Any = new System.Xml.XmlElement[] { nameElement };

updateAccount.type = "Account";

sforceP.SforceService binding = Utility.GetPartnerBinding (this.Context);

//call the update passing an array of object

sforce.SaveResult[] saveResults = binding.update(new sforceP.sObject[] { updateAccount });


System.Xml.XmlDocument doc  does not have a member doc.Xml.XmlElement

Can somebody advise

many thanks

it should be System.Xml.XmlElement nameElement = doc.CreateElement("Name");

Can you tell me where you got the sample code? i'll get it updated.

Message Edited by SimonF on 06-27-2008 07:36 AM
Many thanks for you help Simon
I got the sample code from  the PDF ------ Web Services API Developer's Guide. You can find it on page 75 The method is  updateAccountSample()

The same sample can also be found at:

Once again thankyou for your help


I am getting errors at the following lines (in the same document).

updateAccount.Any = new System.Xml.XmlElement[] { nameElement };
updateAccount.type = "Account";

 Error messages are:

XXXX.Enterprise.sObject' does not contain a definition for 'Any'.
XXXX.Enterprise.sObject' does not contain a definition for 'type'.


This is partner WSDL sample code, you're using the enterprise WSDL.
Where can I find the enterprise WSDL sample code?