The following code demonstrates how to use a Command object and the Views collection Append method to create a new view in the underlying data source.
' BeginCreateViewVB
Sub CreateView()
Dim cmd As New ADODB.Command
Dim cat As New ADOX.Catalog
' Open the Catalog
cat.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\Program Files\Microsoft Office\" & _
"Office\Samples\Northwind.mdb;"
' Create the command representing the view.
cmd.CommandText = "Select * From Customers"
' Create the new View
cat.Views.Append "AllCustomers", cmd
End Sub
' EndCreateViewVB
ActiveConnection Property | Append Method (Views) | Catalog Object | View Object | Views Collection
© 1998-2001 Microsoft Corporation. All rights reserved.