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
BOFHBOFH 

Display Query Results C# .net

Hi all,

I'm new to developing with Sales Force, I just downloaded the Office Tool Kit, and am attempting to run a simple query that should return one record.  I know the record exists, and I know the query is working, since when I run the code, it tells me I am getting one result back.  Here is the C# code that I am running:
                   
                    strSOQL = "Select Name FROM Account where accountnumber = 'xxxxx'";  //Where xxxxx is an account number
                    sfQry = sfObj.Query(strSOQL, sync);
                   
                    //result testing
                    rslt = sfQry.Error.ToString();
                    Console.WriteLine("Error (if any): " + rslt);
                    Console.WriteLine("Result:");
                    count = sfQry.Size;
                    Console.WriteLine("Count: " + count);
                    rslt = sfQry.EntityType;
                    Console.WriteLine("Entity Type: " + rslt);
                    foreach (object obj in sfQry)
                    {
                        result = sfQry.ToString();
                        Console.WriteLine("Query Result: " + result);
                    }

This compiles and runs, when I run it, I get the following result:

Successfully Logged In
Error (if any): NO_SF_ERROR
Result:
Count: 1
Entity Type: account
Query Result: SForceOfficeToolkitLib3.QueryResultSet3Class
Press any key to exit...

I am wondering how to get the program to display the Name instead of printing out: SForceOfficeToolkitLib3.QueryResultSet3Class .

Any and all help is appreciated.

Thanks.
SuperfellSuperfell
You iterate over the query result to get the rows (ISObject's) each row has a fields collection you can iterate over, and each field have a Value property.

You may find the native .NET soap stack easier to work with from C# rather than the office toolkit.
BOFHBOFH
When I tried to iterate through the ISObject, it won't even compile.  The problem I am running into is that the query results need to be stored in an object of type : QueryResultsSet3, which I have not been able to successfully cast into an ISObject.  Can you possibly give me a little more information on this?

You also mentioned using SOAP, could you direct me toward some helpful information on this.  Such as, getting SOAP to interact with SalesForce?

Thanks a bunch.
Gareth DaviesGareth Davies

Seriously - go for the SOAP API.

To get started have a look at the API docs there are good c# examples there. I reccomend starting using the Enterprise API.

Use Salesforce.com to download the WSDL (from setup->integrate) and the add that as a WebReference in you VS Project.

You won't regret it.

Cheers
Gareth.

SuperfellSuperfell
Click the Projects & Toolkit tabs at the top, and download the .NET getting started guide.