この記事ではCData ADO.NET Provider for Freshdesk を使ってPowerBuilder からFreshdesk にアクセスする方法を説明します。
CData ADO.NET providers は、PowerBuilder を含むMicrosoft .NET をサポートするあらゆるプラットフォームまたは開発テクノロジーから使用できる、使いやすい標準準拠のデータプロバイダーです。 この記事では、CData ADO.NET Provider for Freshdesk をPowerBuilder で使う方法について説明します。
CData ADO.NET Provider for Freshdesk を使ってデータを取得し読み書きを実行する基本的なPowerBuilder アプリケーションを作成する方法について説明します。
- 新規WPF Window Application ソリューションで、接続プロパティに必要なすべてのビジュアルコントロールを追加します。一般的な接続文字列は次のとおりです:
Domain=MyDomain;APIKey=myAPIKey;
FreshDesk makes use of basic authentication. To connect to data, set the following connection properties:
- Domain: Set this to the domain associated with your FreshDesk account. For example, in your URL: https://my_domain.freshdesk.com.
- APIKey: Set this to the API key associated with your FreshDesk account. To retrieve your API key, Log into your support Portal -> Click on profile picture in the top right corner -> profile settings page. The API key will be available below the change password section to the right.
- .NET コントロールからDataGrid コントロールを追加します。
-
DataGrid コントロールのカラムを設定します。Account テーブルからいくつかのカラムを以下に示します:
<DataGrid AutoGenerateColumns="False" Margin="13,249,12,14" Name="datagrid1" TabIndex="70" ItemsSource="{Binding}"> <DataGrid.Columns> <DataGridTextColumn x:Name="idColumn" Binding="{Binding Path=Id}" Header="Id" Width="SizeToHeader" /> <DataGridTextColumn x:Name="nameColumn" Binding="{Binding Path=Id}" Header="Id" Width="SizeToHeader" /> ... </DataGrid.Columns> </DataGrid>
- CData ADO.NET Provider for Freshdesk アセンブリへの参照を追加します。
DataGrid 接続
ビジュアルエレメントが設定されたら、Connection、Command、およびDataAdapter のような標準のADO.NET オブジェクトを使ってSQL クエリの結果をDataTable に表示することができます:
System.Data.CData.FreshDesk.FreshDeskConnection conn
conn = create System.Data.CData.FreshDesk.FreshDeskConnection(connectionString)
System.Data.CData.FreshDesk.FreshDeskCommand comm
comm = create System.Data.CData.FreshDesk.FreshDeskCommand(command, conn)
System.Data.DataTable table
table = create System.Data.DataTable
System.Data.CData.FreshDesk.FreshDeskDataAdapter dataAdapter
dataAdapter = create System.Data.CData.FreshDesk.FreshDeskDataAdapter(comm)
dataAdapter.Fill(table)
datagrid1.ItemsSource=table.DefaultView
上のコードは、指定したクエリからDataGrid にデータをバインドできます。