The ADO.NET provider for Salesforce provides a wide range of features that enable connectivity to Salesforce from .Net applications. The documentation will help you understand the C1.AdoNet.Salesforce namespace, which includes all the available classes that can be used to connect and retrieve data from Salesforce.
DataConnectors are mostly used in combination with other ComponentOne components, such as DataEngine and FlexPivot. The procedure below describes how to use the DataConnector in a console application within Visual Studio.
The ADO.NET provider for Salesforce can be used in any application. In this guide, a console application is created:
Follow the steps provided below to learn and implement data retrieval using the ADO.NET provider for Salesforce.
C# |
Copy Code |
---|---|
const string GCSalesforceServerConnectionString = @"Username=*********;Password=*********;Security Token=***********; OAuth Client Id=**************; OAuth Client Secret=*************; OAuth Token Endpoint=https://ap16.salesforce.com/services/oauth2/token; Url=https://ap16.salesforce.com/services/data/v45.0"; |
C# |
Copy Code |
---|---|
String sql = "SELECT Id,BillingCity,BillingState from [Order] limit 10"; using (C1SalesforceConnection c = new C1SalesforceConnection($@"{GCSalesforceServerConnectionString}")) { //Open Connection c.Open(); using (C1SalesforceDataAdapter a = new C1SalesforceDataAdapter(c, sql)) { //Filling Data Table with the help of adapter DataTable t = new DataTable(); a.Fill(t); //Printing the fetched table data on console foreach (DataRow dataRow in t.Rows) { foreach (var item in dataRow.ItemArray) { Console.Write(item + " - "); } Console.WriteLine(); } } } |