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 ADO.NET provider for Salesforce.
C# |
コードのコピー
|
---|---|
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# |
コードのコピー
|
---|---|
String sql = "SELECT Id,BillingCity,BillingState from [Order] limit 10"; using (C1SalesforceConnection c = new C1SalesforceConnection($@"{GCSalesforceServerConnectionString}")) { //接続を開きます。 c.Open(); using (C1SalesforceDataAdapter a = new C1SalesforceDataAdapter(c, sql)) { //アダプターを使用してデータ テーブルを埋めます。 DataTable t = new DataTable(); a.Fill(t); // 取得したテーブルデータをコンソールに出力します。 foreach (DataRow dataRow in t.Rows) { foreach (var item in dataRow.ItemArray) { Console.Write(item + " - "); } Console.WriteLine(); } } } |