クライアントインターフェイスガイド > TDV用TIBCO ADO .NET 2020データプロバイダー > ADO.NETの使用 > コードからの接続
 
コードから接続する
TIBCO(R)データ仮想化用のADO.NETプロバイダーは、CompositeConnectionに標準のDbConnectionオブジェクトを実装します。 CompositeConnectionStringBuilderを使用して、接続文字列をプログラムで構築、解析、および再構築することもできます。
接続オブジェクトの作成
接続文字列の定義と認証のガイドについては、接続の確立を参照してください。以下は、CompositeConnectionオブジェクトを作成するための一般的な呼び出しです。
C#
using (CompositeConnection connection =
new CompositeConnection("Host=myHost;Domain=myDomain;DataSource=myDataSource;User=myUser;Password=myPassword"))
{
connection.Open();
}
VB.NET
Using connection As New CompositeConnection("Host=myHost;Domain=myDomain;DataSource=myDataSource;User=myUser;Password=myPassword")
connection.Open
End Using
CompositeConnectionStringBuilderの使用
次のコード例は、ADO.NET接続文字列ビルダーを使用して接続文字列を解析する方法を示しています。
C#
 
CompositeConnectionStringBuilder builder =
new CompositeConnectionStringBuilder("Host=myHost;Domain=myDomain;DataSource=myDataSource;User=myUser;Password=myPassword");
//Pass the connection string builder an existing connection string, and you can get and set any of the elements as strongly typed properties.
builder.ConnectionString = "Host=myHost;Domain=myDomain;DataSource=myDataSource;User=myUser;Password=myPassword";
//Now that the connection string has been parsed,
// you can work with individual items:
builder.MyString = "new property";
builder.MyBoolean = true;
// You can refer to connection keys using strings,
// as well.
builder["Logfile"] = "test.log";
builder["Verbosity"] = 5;
 
VB.NET
 
Dim builder As CompositeConnectionStringBuilder = New CompositeConnectionStringBuilder("Host=myHost;Domain=myDomain;DataSource=myDataSource;User=myUser;Password=myPassword")
'Pass the connection string builder an existing connection string, and you can get and set any of the elements using strongly typed properties.
builder.ConnectionString = Host=myHost;Domain=myDomain;DataSource=myDataSource;User=myUser;Password=myPassword"
'Now that the connection string has been parsed,
' you can work with individual items:
builder.MyString = "new property"
builder.MyBoolean = True
' You can refer to connection keys using strings,
' as well.
builder("Logfile") = "test.log"
builder("Verbosity") = 5