次の方法で共有


DataAdaptersCollection インターフェイス

Microsoft Office InfoPath 2007 フォームで使用される各データ接続に対応するデータ アダプタ オブジェクトを格納します。

 

名前空間: Microsoft.Office.Interop.InfoPath.SemiTrust
アセンブリ: Microsoft.Office.Interop.InfoPath.SemiTrust (microsoft.office.interop.infopath.semitrust.dll 内)

構文

'宣言
<CoClassAttribute(GetType(DataAdaptersCollectionWrapper))> _
<GuidAttribute("096cd692-0786-11d1-95fa-0080c78ee3bb")> _
<CLSCompliantAttribute(False)> _
Public Interface DataAdaptersCollection
    Inherits DataAdapters
'使用
Dim instance As DataAdaptersCollection
[CoClassAttribute(typeof(DataAdaptersCollectionWrapper))] 
[GuidAttribute("096cd692-0786-11d1-95fa-0080c78ee3bb")] 
[CLSCompliantAttribute(false)] 
public interface DataAdaptersCollection : DataAdapters

コメント

この型は、COM 相互運用のためにマネージ コードで必要とされるコクラスのラッパーです。この型を使用して、このコクラスによって実装される COM インターフェイスのメンバにアクセスします。COM インターフェイスについては (このメンバの説明へのリンクを含む)、次を参照してください DataAdapters

各データ接続は、メイン データ ソースまたはセカンダリ データ ソースに挿入されたデータを取得したり、データを送信したりするために使用されます。

メイン データ ソースのデータの取得に使用されるデータ接続は、次のいずれかの種類のデータ アダプタ オブジェクトに対応します。

メモメモ :

メイン データ ソースのデータの取得に使用される ADOAdapter オブジェクトは、データを送信することもできます。

セカンダリ データ ソースのデータの取得に使用されるデータ接続は、次のいずれかの種類のデータ アダプタ オブジェクトに対応します。

データの送信のみに使用されるデータ接続は、次のいずれかの種類のデータ アダプタ オブジェクトに対応します。

DataAdapters コレクションには、XDocument オブジェクトの DataAdapters プロパティを使用してアクセスすることができます。

メモメモ :

データ アダプタ オブジェクトのプロパティやメソッドを使用するには、これらのメンバにアクセスする前に、DataAdaptersCollection オブジェクトから返されたオブジェクトを、そのオブジェクトが表す特定のデータ アダプタにキャストする必要があります。データ アダプタの操作の詳細については、「[方法] InfoPath 2003 オブジェクト モデルを使用して外部データ ソースにアクセスする方法」を参照してください。

次の例では、Northwind データベースの Employees テーブルに接続されている ADOAdapter オブジェクトを DataAdapters コレクションから取得します。

// retrieve the Employees Adapter from the DataAdapters collection
ADOAdapter employeesDA = (ADOAdapter)thisXDocument.DataAdapters["Employees"];

次の例では、XML ファイル データ接続として使用できる、"form1" という名前の XML ドキュメントを、DataAdapters コレクションから取得します。この接続のさまざまなプロパティがメッセージ ボックスに表示されます。

DataAdapters dataAdapters;
XMLFileAdapterObject xmlFileAdapterObject;

dataAdapters = thisXDocument.DataAdapters; 
xmlFileAdapterObject = dataAdapters["form1"] as XMLFileAdapterObject;

if (xmlFileAdapterObject == null)
{
 thisXDocument.UI.Alert("The DataAdapter does not exist or is not an XMLFileAdapterObject.");
}
else
{
 thisXDocument.UI.Alert("XML file adapter" + "\n\n" + "Name: " + xmlFileAdapterObject.Name + "\n" + "QueryAllowed: " + xmlFileAdapterObject.QueryAllowed+ "\n" + "SubmitAllowed: " + xmlFileAdapterObject.SubmitAllowed+ "\n" + "FileURL: " + xmlFileAdapterObject.FileURL);

 // Perform the query.
 try
 {
  xmlFileAdapterObject.Query();
 }
 catch (Exception ex)
 {
  thisXDocument.UI.Alert("Failed to query.\n\n" + ex.Message);
 }

 // Perform the submit.
 try
 {
  xmlFileAdapterObject.Submit();
 }
 catch (Exception ex)
 {
  thisXDocument.UI.Alert("Failed to submit.\n\n" + ex.Message);
 }
}

関連項目

参照

DataAdaptersCollection のメンバ
Microsoft.Office.Interop.InfoPath.SemiTrust 名前空間