Q:

SharePoint 2013 Batch update list items C# SSOM

I am trying to use batch update for one of the list in SP2013 site. I am trying to run a simple batch request as follows.
        using (var spSite = new SPSite(siteName))
        using (var spWeb = spSite.OpenWeb())
        {

            var clientList = spWeb.Lists["Clients"];

            string batchFormat = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<ows:Batch OnError=\"Return\">"
            +"<Method ID=\"{0}\">" +
             "<SetList>{1}</SetList>" +
             "<SetVar Name=\"Cmd\">Save</SetVar>" +
             "<SetVar Name=\"ID\">{2}</SetVar>" +
             "<SetVar Name=\"InstitutionType\">{3}</SetVar>" +
            "</Method>"+"</ows:Batch>", 1, clientList.ID,833, "None");

            spWeb.AllowUnsafeUpdates = true;
            spWeb.ProcessBatchData(batchFormat);

        }

And I am getting response of spWeb.ProcessBatchData(batchFormat); as
<Results><Result ID="1" Code="0">
</Result>
</Results>

Can anyone please suggest me what is the correct way to perform batch updates. It runs but nothing is updated in list. 
Thanks.

A:

In your code you have set ID 833, so it will only update the item which has ID 833.
Modify your code as below:
using (SPSite spSite = new SPSite(siteName))
{
    using (SPWeb spWeb = spSite.OpenWeb())
    {
        spWeb.AllowUnsafeUpdates = true;

        StringBuilder methodBuilder = new StringBuilder();
        string batch = string.Empty;
        string batchFormat = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
        "<Batch OnError=\"Return\">{0}</Batch>";

        string methodFormat = "<Method ID=\"{0}\">" +
        "<SetList>{1}</SetList>" +
        "<SetVar Name=\"Cmd\">Save</SetVar>" +
        "<SetVar Name=\"ID\">{2}</SetVar>" +
        "<SetVar Name=\"urn:schemas-microsoft-com:office:office#InstitutionType\">{3}</SetVar>" +
        "</Method>";

        SPList list = spWeb.Lists.TryGetList("Clients");
        if(list!=null)
        {
            SPQuery query = new SPQuery();
            query.Query = "<View/>";
            SPListItemCollection listItem = list.GetItems(query);

            foreach (SPListItem item in listItem)
            {
                methodBuilder.AppendFormat(methodFormat, item.ID, list.ID, item.ID, "None");
            }

            batch = string.Format(batchFormat, methodBuilder.ToString());

            // Process the batch of commands.
            string batchReturn = spWeb.ProcessBatchData(batch);
            spWeb.AllowUnsafeUpdates = false;
        }
    }
}

