IDbViewManager.CreateView Method
Creates a view within the database.
Namespace: Microsoft.Web.Management.DatabaseManager
Assembly: Microsoft.Web.Management.DatabaseManager (in Microsoft.Web.Management.DatabaseManager.dll)
Syntax
'Declaration
Sub CreateView ( _
connectionString As String, _
schema As String, _
view As View _
)
'Usage
Dim instance As IDbViewManager
Dim connectionString As String
Dim schema As String
Dim view As View
instance.CreateView(connectionString, _
schema, view)
void CreateView(
string connectionString,
string schema,
View view
)
void CreateView(
String^ connectionString,
String^ schema,
View^ view
)
function CreateView(
connectionString : String,
schema : String,
view : View
)
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.
- view
Type: Microsoft.Web.Management.DatabaseManager.View
The View object for the view to create.
Remarks
All database providers that implement the IDbViewManager interface must also implement the CreateView method, which the database manager will use to create a view in a database.
Notes for Implementers
If your provider does not support creating views, you can use the following code sample to raise a not-implemented exception:
public void CreateView(string connectionString, string schema, View view)
{
throw new NotImplementedException();
}
Note
See the CREATE VIEW (Transact-SQL) topic for more information about the CREATE VIEW SQL statement.
Examples
The following code sample implements the CreateView method to add a view to a database in an OLEDB data source.
' Remove a view from the database.
Public Sub DropView( _
ByVal connectionString As String, _
ByVal schema As String, _
ByVal viewName As String) _
Implements Microsoft.Web.Management.DatabaseManager.IDbViewManager.DropView
' Create a new database connection.
Dim connection As OleDbConnection = New OleDbConnection(connectionString)
' Create the SQL for the CREATE VIEW statement.
Dim dropView As String = String.Format("DROP VIEW {0}", EscapeName(viewName))
' Create an OLEDB command object.
Dim command As OleDbCommand = New OleDbCommand(dropView, connection)
' Open the database connection.
connection.Open()
' Execute the SQL statement.
command.ExecuteNonQuery()
End Sub
// 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();
}
}
}
Permissions
- 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.