Salesforce Connector for C#

In this article you will learn how to quickly and efficiently integrate Salesforce data in C#. We will use high-performance Salesforce Connector to easily connect to Salesforce and then access the data inside C#.

Salesforce Connector can be used to extract/load large amount of data from/in Salesforce.com without any programming. You can use simple Table mode or Query mode with full SOQL query language support (SOQL=Salesforce.com Object Query Language).

Let's follow the steps below to see how we can accomplish that!

Download Documentation

Create ODBC Data Source (DSN) based on ZappySys Salesforce Driver

Step-by-step instructions

To get data from Salesforce using C# we first need to create a DSN (Data Source) which will access data from Salesforce. We will later be able to read data using C#. Perform these steps:

  1. Install ZappySys ODBC PowerPack.

  2. Open ODBC Data Sources (x64):

    Open ODBC Data Source
  3. Create a User data source (User DSN) based on ZappySys Salesforce Driver

    ZappySys Salesforce Driver
    Create new User DSN for ZappySys Salesforce Driver
    • Create and use User DSN if the client application is run under a User Account. This is an ideal option in design-time, when developing a solution, e.g. in Visual Studio 2019. Use it for both type of applications - 64-bit and 32-bit.
    • Create and use System DSN if the client application is launched under a System Account, e.g. as a Windows Service. Usually, this is an ideal option to use in a production environment. Use ODBC Data Source Administrator (32-bit), instead of 64-bit version, if Windows Service is a 32-bit application.
  4. Now, we need SalesForce Connection. Lets create it. ODBC SalesForce Driver - Create Connection

  5. Now, When you see DSN Config Editor with zappysys logo first thing you need to do is change default DSN Name at the top and Click on Preview Tab, Select Table from Tables Dropdown or you can enter or modify a SOQL query and click on Preview Data.
    This example shows how to write simple SOQL query (Salesforce Object Query Language). It uses WHERE clause. For more SOQL Queries click here.
    SOQL is similar to database SQL query language but much simpler and many features you use in database query may not be supported in SOQL (Such as JOIN clause not supported). But you can use following Queries for Insert, Update, Delete and Upsert(Update or Insert record if not found).

    SELECT * FROM Account WHERE Name like '%Oil%'
    ZappySys ODBC Driver - Select Table and Preview Data
  6. Click OK to finish creating the data source

Video instructions

Read data in C#

Using ODBC DSN

  1. Create a new Console project and use this code to read the data:

    "SalesforceDSN";
    Make ZappySys Driver call in c#

  2. Press F5 to run the code and read the data:
    ZappySys Driver Output in c#

  3. Here is the code in text format:

    using System;
    using System.Data.Odbc;
    
    namespace ConsoleApp {
        class Program {
            static void Main() {
                var dsn = "SalesforceDSN";
                using (var conn = new OdbcConnection(String.Format("DSN={0}", dsn)))
                {
                    conn.Open();
                    var cmd = new OdbcCommand("SELECT * FROM Products", conn);
                    
                    //Increase the timeout duration from the default 30 seconds, which may be insufficient in certain scenarios
                    cmd.CommandTimeout=600; // 600-Seconds
                    
                    var rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        for (int i = 0; i < rdr.FieldCount; i++)
                        {
                                Console.Write("{0}\t", rdr[i]);
                        }
                        Console.WriteLine();
                    }
                }
                Console.ReadKey();
            }
        }
    }
    

Using a full ODBC connection string

If you want to avoid being dependent on a DSN and creating multiple DSNs for each platform (x86, x64), then you can use a fully qualified connection string. Simply go to your DSN and copy the Connection String:

  1. Open ODBC data source configuration and click Copy settings:
    ZappySys Salesforce Driver - Salesforce
    Salesforce Connector can be used to extract/load large amount of data from/in Salesforce.com without any programming. You can use simple Table mode or Query mode with full SOQL query language support (SOQL=Salesforce.com Object Query Language).
    SalesforceDSN
    Copy connection string for ODBC application
  2. The window opens, telling us the connection string was successfully copied to the clipboard: Successful connection string copying for ODBC application
  3. Then in your C# code, pass the connection string as an argument when calling the OdbcConnection object's constructor, for example:

    var connectionString = @"DRIVER={ZappySys Salesforce Driver};Url='https://login.salesforce.com/services/Soap/u/{version}';Scopes='full offline_access';UserName='john.smith@my-company.com';Password='my-password';SecurityToken='my-security-token'";
    
    using (var conn = new OdbcConnection(connectionString))
    {
        // your code goes here
    }

Conclusion

In this article we showed you how to connect to Salesforce in C# and integrate data without any coding, saving you time and effort. We encourage you to download Salesforce Connector for C# and see how easy it is to use it for yourself or your team.

If you have any questions, feel free to contact ZappySys support team. You can also open a live chat immediately by clicking on the chat icon below.

Download Salesforce Connector for C# Documentation

More integrations

Other connectors for C#

Other application integration scenarios for Salesforce

  • How to connect Salesforce in C#?

  • How to get Salesforce data in C#?

  • How to read Salesforce data in C#?

  • How to load Salesforce data in C#?

  • How to import Salesforce data in C#?

  • How to pull Salesforce data in C#?

  • How to push data to Salesforce in C#?

  • How to write data to Salesforce in C#?

  • How to POST data to Salesforce in C#?

  • Call Salesforce API in C#

  • Consume Salesforce API in C#

  • Salesforce C# Automate

  • Salesforce C# Integration

  • Integration Salesforce in C#

  • Consume real-time Salesforce data in C#

  • Consume real-time Salesforce API data in C#

  • Salesforce ODBC Driver | ODBC Driver for Salesforce | ODBC Salesforce Driver | SSIS Salesforce Source | SSIS Salesforce Destination

  • Connect Salesforce in C#

  • Load Salesforce in C#

  • Load Salesforce data in C#

  • Read Salesforce data in C#

  • Salesforce API Call in C#