Rhyous

October 15, 2009

How to connect to Salesforce / SForce with C#?

Filed under: C# (C-Sharp),Salesforce / SForce — J. Abram barneck @ 6:00 am

Step 1 – Download and import the wsdl (sorry no steps for this here yet).

Step 2 – Use the following code example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace SforceConnection
{
    public class Program
    {
        static void Main(string[] args)
        {
            SforceService service = new SforceService();
            LoginResult loginResult = new LoginResult();
            string username= "youruser@yourdomain.tld";
            string password= "P@sswd!";
            service.Timeout = 60000;
            loginResult  = service.login(username, password);
            service.Url = loginResult.serverUrl;
            service.SessionHeaderValue = new SessionHeader();
            service.SessionHeaderValue.sessionId = loginResult.sessionId;
            
            // Do something you are now connected

        }
    }
}
Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: