AdoSubmitConnection.Connection プロパティ
AdoSubmitConnection オブジェクトに使用される接続文字列を取得または設定します。
名前空間: Microsoft.Office.InfoPath
アセンブリ: Microsoft.Office.InfoPath (microsoft.office.infopath.dll 内)
構文
'宣言
Public MustOverride Property Connection As String
'使用
Dim instance As AdoSubmitConnection
Dim value As String
value = instance.Connection
instance.Connection = value
public abstract string Connection { get; set; }
プロパティ値
データ接続の接続文字列。
コメント
ADOSubmitConnection オブジェクトの Connection プロパティは、ActiveX Data Objects/OLEDB 外部データ ソースに接続するために ADO データ接続によって使用される接続文字列へのアクセスを提供します。
重要 : |
---|
ADOSubmitConnection オブジェクトが存在できるのは、対応する ADOQueryConnection オブジェクトがあり、両方のオブジェクトで表されるデータ接続で、同じプロパティ値のセットを共有している場合のみです。ADOSubmitConnection オブジェクトのこのプロパティの値を変更すると、対応する ADOQueryConnection オブジェクトの同じプロパティの値も変更されます。 |
メモ : |
---|
ADOSubmitConnection オブジェクトが機能するのは、Microsoft SQL Server および Microsoft Access データベースのみに限定されています。 |
このメンバは、現在開いているフォームと同じドメイン内で実行されているフォーム、またはドメインを越えたアクセス許可を付与されているフォームだけがアクセスできます。
この型またはメンバは、Microsoft Office InfoPath 2007 で開いているフォームで実行されているコードからのみアクセスできます。
例
次の例では、[ボタン] コントロールのイベント ハンドラは AdoSubmitConnection クラスの Connection プロパティを使用して、Employees という名前のセカンダリ データ ソースの接続文字列を更新し、メイン データ ソースの ServerName フィールドに入力した値を使用して新しいサーバーを示します。次に、DataConnection クラスの Execute メソッドを使用して、新しいサーバーのデータ接続が再クエリされます。
public void ChangeServerName_Clicked(object sender, ClickedEventArgs e)
{
// Get the Employees connection from the
//DataConnections collection.
AdoSubmitConnection myAdoSubmitConnection =
(AdoSubmitConnection)(this.DataConnections["Employees"]);
// Get the new server name from the ServerName field in
// the main data source.
XPathNavigator myNav =
CreateNavigator().SelectSingleNode("/my:myFields/my:ServerName",
NamespaceManager);
string newServer = myNav.InnerXml;
// Build the new connection string.
string connectionString =
"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;";
connectionString += "Initial Catalog=SalesDB;Data Source=" +
newServer;
// Set the new connection string.
myAdoSubmitConnection.Connection = connectionString;
// Requery the data source.
myAdoSubmitConnection.Execute();
}
Public Sub ChangeServerName_Clicked(ByVal sender As Object, _
ByVal e As ClickedEventArgs)
' Get the Employees connection from
' the DataConnections collection.
Dim myAdoSubmitConnection As AdoSubmitConnection = _
DirectCast(Me.DataConnections("Employees"), AdoSubmitConnection)
' Get the new server name from the ServerName field in
' the main data source.
Dim myNav As XPathNavigator = _
CreateNavigator().SelectSingleNode("/my:myFields/my:ServerName", _
NamespaceManager)
Dim newServer As String = myNav.InnerXml
' Build the new connection string.
Dim connectionString As String = _
"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;"
connectionString = connectionString & _
"Initial Catalog=SalesDB;Data Source=" & newServer
' Requery the data source.
myAdoSubmitConnection.Execute()
End Sub
関連項目
参照
AdoSubmitConnection クラス
AdoSubmitConnection のメンバ
Microsoft.Office.InfoPath 名前空間