SqlConnection::Database Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the name of the current database or the database to be used after a connection is opened.

Namespace:   System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)

public:
property String^ Database {
	virtual String^ get() override;
}

Property Value

Type: System::String^

The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string.

The Database property updates dynamically. If you change the current database using a Transact-SQL statement or the ChangeDatabase method, an informational message is sent and the property is updated automatically.

The following example creates a SqlConnection and displays some of its read-only properties.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: