Database Class

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

Inheritance Hierarchy

System.Object
  WebMatrix.Data.Database

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

Syntax

'Declaration
Public Class Database _
    Implements IDisposable
'Usage
Dim instance As Database
public class Database : IDisposable
public ref class Database : IDisposable
type Database =  
    class 
        interface IDisposable 
    end
public class Database implements IDisposable

The Database type exposes the following members.

Properties

  Name Description
Public property Connection Gets the current connection to a database.

Top

Methods

  Name Description
Public method Close Closes an open database.
Public method Dispose() Releases all resources used by a Database instance.
Protected method Dispose(Boolean) Releases the unmanaged resources used by a Database instance and optionally releases the managed resources.
Public method Equals (Inherited from Object.)
Public method Execute Executes a non-query SQL statement.
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetLastInsertId Returns the identity column of the most recently inserted row.
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public methodStatic member Open Opens a connection to a database using the specified file name or using the named connection string.
Public methodStatic member OpenConnectionString(String) Opens a connection to a database using the specified connection string.
Public methodStatic member OpenConnectionString(String, String) Opens a connection to a database using a connection string and the specified provider.
Public method Query Executes a SQL query that returns a list of rows as the result.
Public method QuerySingle Executes a SQL query that returns a single row as the result.
Public method QueryValue Executes a SQL query that returns a single scalar value as the result.
Public method ToString (Inherited from Object.)

Top

Events

  Name Description
Public eventStatic member ConnectionOpened Occurs when a new database connection is opened by a Database instance.

Top

Remarks

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.

Thread Safety

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

See Also

Reference

WebMatrix.Data Namespace

Other Resources

Working with Data