So I have a C# program that does an automated backup of all custom objects in are org in the login method which I have posted below I set the querybatch size

    private bool login()
            binding = new SforceService();
            binding.Timeout = 180000;
            lr = binding.login("username", "password+token");
            binding.Url = lr.serverUrl;
            binding.SessionHeaderValue = new SessionHeader { sessionId = lr.sessionId };
            binding.QueryOptionsValue = new SforceBackup.QueryOptions();
            binding.QueryOptionsValue.batchSize = 50;
            binding.QueryOptionsValue.batchSizeSpecified = true;
            return true;
        catch (SoapException e)
            using (StreamWriter writer =
             new StreamWriter("somefile", true))

        return false;

Later in my code i build an sqlbody and query it with the following line

QueryResult qr = binding.queryAll("Select " + sqlbody + "From " + objectname + " where isdeleted=false");

But when I set the Sobject array to sObject[] records = qr.records; it alway returns 200 records

****Note the whole program runs to completion but occasionally times out with some larger objects (800 fields) in are org on this line ***

qr = binding.queryMore(qr.queryLocator);

So I figure if I can set the batchsize it should take care of the problem but no matter where I set it in the program I get 200 records return(I checked the stack with a breakpoint and its being set there).

**Note not interested in Salesforce weekly backup or anything on the appexchange.


i guess you cannot go lower than 200 as per QueryOptions documentation:

The default is 500; the minimum is 200, and the maximum is 2,000. There is no guarantee that the requested batch size will be the actual batch size; this is done to maximize performance.

  • Thanks some much pnoytechie didn't see that in the documentation. What I had to do is handle the larger objects in a separate function using and id in query that a generated and when that function is finished log out because on concurrent api request then log back in and run the rest of the objects – michaelBehan Sep 28 '15 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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