private bool login()
        {
            Console.Write("Enter username: "******"Enter password: "******"\nLogging in...\n");
                lr = binding.login(username, password);
            }

            // ApiFault is a proxy stub generated from the WSDL contract when
            // the web service was imported
            catch (SoapException e)
            {
                // Write the fault code to the console
                Console.WriteLine(e.Code);

                // Write the fault message to the console
                Console.WriteLine("An unexpected error has occurred: " + e.Message);

                // Write the stack trace to the console
                Console.WriteLine(e.StackTrace);

                // Return False to indicate that the login was not successful
                return(false);
            }

            // Check if the password has expired
            if (lr.passwordExpired)
            {
                Console.WriteLine("An error has occurred. Your password has expired.");
                return(false);
            }

            // Set the returned service endpoint URL
            binding.Url = lr.serverUrl;

            // Set the SOAP header with the session ID returned by
            // the login result. This will be included in all
            // API calls.
            binding.SessionHeaderValue           = new CaseContentExpoter.sforce.SessionHeader();
            binding.SessionHeaderValue.sessionId = lr.sessionId;

            // Return true to indicate that we are logged in, pointed
            // at the right URL and have our security token in place.
            return(true);
        }
        private List <sObject> queryRecords(CaseContentExpoter.sforce.SforceService binding, String queryStr)
        {
            List <sObject> listofResponse = new List <sObject>();

            try
            {
                QueryResult qr = null;
                binding.QueryOptionsValue                    = new sforce.QueryOptions();
                binding.QueryOptionsValue.batchSize          = 250;
                binding.QueryOptionsValue.batchSizeSpecified = true;

                qr = binding.query(queryStr);

                bool done = false;
                //int loopCount = 0;
                while (!done)
                {
                    // Process the query results
                    listofResponse.AddRange(qr.records);

                    if (qr.done)
                    {
                        done = true;
                    }
                    else
                    {
                        qr = binding.queryMore(qr.queryLocator);
                    }
                }
            }
            catch (SoapException e)
            {
                Console.WriteLine("An unexpected error has occurred: " + e.Message +
                                  " Stack trace: " + e.StackTrace);
            }
            return(listofResponse);
        }