ADOX 2.7

Views Collection, CommandText Property Example (VB)

The following code demonstrates how to use the Command property to update the text of a view.

' BeginViewsCollectionVB
Sub ViewText()

   Dim cnn As New ADODB.Connection
   Dim cat As New ADOX.Catalog
   Dim cmd As New ADODB.Command

   ' Open the Connection
   cnn.Open _
      "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=c:\Program Files\Microsoft Office\" & _
      "Office\Samples\Northwind.mdb;"

   ' Open the catalog
   Set cat.ActiveConnection = cnn

   ' Get the command
   Set cmd = cat.Views("AllCustomers").Command

   ' Update the CommandText of the Command
   cmd.CommandText = _
      "Select CustomerId, CompanyName, ContactName From Customers"

   ' Update the View
   Set cat.Views("AllCustomers").Command = cmd

End Sub
' EndViewsCollectionVB

See Also

ActiveConnection Property | Catalog Object | Command Property | View Object | Views Collection

© 1998-2001 Microsoft Corporation. All rights reserved.