title | TOCTitle | description | ms:assetid | ms:mtpsurl | ms:contentKeyID | ms.date | mtps_version | f1_keywords | dev_langs | api_location | api_name | api_type | topic_type | product_family_name | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DatabaseProvider.TestConnection Method (Microsoft.Web.Management.DatabaseManager) |
TestConnection Method |
The DatabaseProvider.TestConnection method tests a connection string for a database provider. This article describes its syntax, remarks, examples, and permissions. |
M:Microsoft.Web.Management.DatabaseManager.DatabaseProvider.TestConnection(System.String) |
20476646 |
05/02/2012 |
v=VS.90 |
|
|
|
|
|
|
VS |
Tests a connection string for a database provider.
Namespace: Microsoft.Web.Management.DatabaseManager
Assembly: Microsoft.Web.Management.DatabaseManager (in Microsoft.Web.Management.DatabaseManager.dll)
'Declaration
Public MustOverride Sub TestConnection ( _
connectionString As String _
)
'Usage
Dim instance As DatabaseProvider
Dim connectionString As String
instance.TestConnection(connectionString)
public abstract void TestConnection(
string connectionString
)
public:
virtual void TestConnection(
String^ connectionString
) abstract
public abstract function TestConnection(
connectionString : String
)
- connectionString
Type: System.String
The connection string to test.
Your provider must implement the TestConnection method in order to test the database connection for your provider.
The following code sample illustrates an example TestConnection method that opens and closes a database that will test the connection.
Public Overrides Sub TestConnection(ByVal connectionString As String)
Dim connection As OleDbConnection = New OleDbConnection(connectionString)
connection.Open()
connection.Close()
End Sub
public override void TestConnection(
string connectionString )
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
connection.Open();
connection.Close();
}
}
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.