views:

22

answers:

1

Hi,

Does anyone have any recomendations of how to improve the performance of the UpdateListItems function (Within Lists.asmx)

Im finding that it takes around 1-2 seconds to insert a new item, is this normal?

Heres the code im which im running inside a loop, which runs about 1000 times

Dim xmlDoc As New System.Xml.XmlDocument()
Dim query As System.Xml.XmlElement = xmlDoc.CreateElement("Batch")

query.SetAttribute("OnError", "Return")
query.SetAttribute("ListVersion", "1")

query.InnerXml = "<Method ID='1' Cmd='New'>" & _
                 "<Field Name='FieldName'>" & FieldData & "</Field>" & _
                 "</Method>"

Dim Result As XmlElement = L.UpdateListItems("List Name", query)

Thanks in advance!

+1  A: 

You can do multiple updates in one call to the web service - i.e call the update outside ofthe loop.

So you can send to UpdateListItems like this which will update 2 record in a batch.

<Batch OnError="Continue" ListVersion="1" 
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2">
   <Method ID="1" Cmd="Update">
      <Field Name="ID">4<Field>
      <Field Name="Field_Name">Value</Field>
   </Method>
   <Method ID="2" Cmd="Update">
      <Field Name="ID" >6</Field>
      <Field Name="Field_Name">Value</Field>
   </Method>
</Batch>
Ryan
Nice one!... I Was looking to hard for other solutions, when infact I should have just read the docs! Thanks
Sean Taylor