Database Class

Provides methods and properties that are used to access and manage data that is stored in a database.


Namespace:  WebMatrix.Data
Assembly:  WebMatrix.Data (in WebMatrix.Data.dll)

public ref class Database : IDisposable

The Database type exposes the following members.

Public propertyConnectionGets the current connection to a database.

Public methodCloseCloses an open database.
Public methodDispose()Releases all resources used by a Database instance.
Protected methodDispose(Boolean)Releases the unmanaged resources used by a Database instance and optionally releases the managed resources.
Public methodEquals (Inherited from Object.)
Public methodExecuteExecutes a non-query SQL statement.
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetLastInsertIdReturns the identity column of the most recently inserted row.
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodStatic memberOpenOpens a connection to a database using the specified file name or using the named connection string.
Public methodStatic memberOpenConnectionString(String)Opens a connection to a database using the specified connection string.
Public methodStatic memberOpenConnectionString(String, String)Opens a connection to a database using a connection string and the specified provider.
Public methodQueryExecutes a SQL query that returns a list of rows as the result.
Public methodQuerySingleExecutes a SQL query that returns a single row as the result.
Public methodQueryValueExecutes a SQL query that returns a single scalar value as the result.
Public methodToString (Inherited from Object.)

Public eventStatic memberConnectionOpenedOccurs when a new database connection is opened by a Database instance.

This class represents a helper, which is a component that simplifies Web programming in ASP.NET Web Pages. You can use the Database class to open, read, and update a database.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.