Bagikan melalui


IDbConnection.ConnectionString Properti

Definisi

Mendapatkan atau mengatur string yang digunakan untuk membuka database.

public:
 property System::String ^ ConnectionString { System::String ^ get(); void set(System::String ^ value); };
public string ConnectionString { get; set; }
member this.ConnectionString : string with get, set
Public Property ConnectionString As String

Nilai Properti

String yang berisi pengaturan koneksi.

Contoh

Contoh berikut membuat instans kelas turunan, OleDbConnection, mengatur ConnectionString, dan menampilkan State.

public void CreateOleDbConnection(){
   OleDbConnection connection = new OleDbConnection();
   connection.ConnectionString =
       "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb";
   Console.WriteLine("Connection State: " + connection.State.ToString());
}
Public Sub CreateOleDbConnection()
    Dim connection As New OleDbConnection()
    connection.ConnectionString = _
       "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb"
    Console.WriteLine("Connection State: " & connection.State.ToString())
End Sub

Keterangan

ConnectionString Properti hanya dapat diatur saat koneksi ditutup.

Berlaku untuk