Export (0) Print
Expand All

IDbViewManager.DropView Method

IIS 7.0

Removes a view from the database.

Namespace:  Microsoft.Web.Management.DatabaseManager
Assembly:  Microsoft.Web.Management.DatabaseManager (in Microsoft.Web.Management.DatabaseManager.dll)

void DropView(
	string connectionString,
	string schema,
	string viewName
)

Parameters

connectionString
Type: System.String
The connection string for the database.
schema
Type: System.String
The schema name for the view.
Note   If schema is empty, the default schema name will be used.
viewName
Type: System.String
The name of the view to drop.

All database providers that implement the IDbViewManager interface must also implement the DropView method, which the database manager will use to remove a view from a database.

Notes for Implementers

If your provider does not support deleting views, you can use the following code sample to raise a not-implemented exception:

public void DropView(string connectionString, string schema, string viewName)

{

   throw new NotImplementedException();

}

NoteNote:

See the DROP VIEW (Transact-SQL) topic for more information about the DROP VIEW SQL statement.

The following code sample implements the DropView method to remove a view from a database in an OLEDB data source.



        // Remove a view from the database.
        public void DropView(string connectionString, string schema, string viewName)
        {
            // Create a new database connection.
            using (OleDbConnection connection = new OleDbConnection(connectionString))
            {
                // Create the SQL for the CREATE VIEW statement.
                string dropView = String.Format("DROP VIEW {0}", EscapeName(viewName));
                // Create an OLEDB command object.
                using (OleDbCommand command = new OleDbCommand(dropView, connection))
                {
                    // Open the database connection.
                    connection.Open();
                    // Execute the SQL statement.
                    command.ExecuteNonQuery();
                }
            }
        }



Show:
© 2014 Microsoft