Salesforce Connector for C# How to Test Connection

Introduction

In this article we will delve deeper into Salesforce and C# integration, and will learn how to test connection. We are continuing from where we left off. By this time, you must have installed ODBC PowerPack, created ODBC Data Source, and configured authentication settings in your Salesforce account .

So, let's not waste time and begin.

Use Query Builder to generate SQL query

  1. The first thing you have to do is open Query Builder:

    ZappySys API Driver - Salesforce
    Amazon Ads Connector can be used to get Amazon advertisements using Amazon Advertisements API, download various advertisement-related reports.
    SalesforceDSN
    Open Query Builder in API ODBC Driver to read and write data to REST API
  2. Then simply select the Test Connection endpoint (action).

  3. Continue by configuring the Required parameters. You can also set optional parameters too.

  4. Move on by hitting Preview Data button to preview the results.

  5. If you see the results you need, simply copy the generated query:

    Test Connection
    This Endpoint has no parameters.
    SELECT * FROM test_connection
    Query Builder
  6. That's it! You can use this query in C#.

Let's not stop here and explore SQL query examples, including how to use them in Stored Procedures and Views (virtual tables) in the next steps.

SQL query examples

Use these SQL queries in your C# data source:

How to Test connection

SELECT * FROM test_connection

Test Connection in C#

  1. Use this code snippet to read the data using SalesforceDSN data source:

    "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();
            }
        }
    }
    

More actions supported by Salesforce Connector

Learn how to perform other actions directly in C# with these how-to guides:

More integrations

All
Data Integration
Database
BI & Reporting
Productivity
Programming Languages
Automation & Scripting
ODBC applications