视图文本范例

目录

如下代码演示如何使用 Command 属性更新视图的文本。

Sub ViewText()   Dim cnn As New ADODB.Connection
   Dim cat As New ADOX.Catalog
   Dim cmd As New ADODB.Command   ' 打开连接
   cnn.Open _
      "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=c:\Program Files\Microsoft Office\" & _
      "Office\Samples\Northwind.mdb;"   ' 打开目录
   Set cat.ActiveConnection = cnn   ' 获得 Command
   Set cmd = cat.Views("AllCustomers").Command   ' 更新 Command 的 CommandText
   cmd.CommandText = _
      "Select CustomerId, CompanyName, ContactName From Customers"   ' 更新视图
   Set cat.Views("AllCustomers").Command. = cmdEnd Sub
www.2mysite.net