MDAC 2.5 SDK - ADOX


 

Views Collection, CommandText Property Example (VB)

See Also

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

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