Condividi tramite


Esempio del metodo Append di Views (VB)

Il codice seguente illustra come usare un oggetto Command e il metodo Append della raccolta Views per creare una nuova visualizzazione nell'origine dati sottostante.

' BeginCreateViewVB  
Sub Main()  
    On Error GoTo CreateViewError  
  
    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='Northwind.mdb';"  
  
    ' Create the command representing the view.  
    cmd.CommandText = "Select * From Customers"  
  
    ' Create the new View  
    cat.Views.Append "AllCustomers", cmd  
  
    'Clean up  
    Set cat.ActiveConnection = Nothing  
    Set cat = Nothing  
    Set cmd = Nothing  
    Exit Sub  
  
CreateViewError:  
  
    Set cat = Nothing  
    Set cmd = Nothing  
  
    If Err <> 0 Then  
        MsgBox Err.Source & "-->" & Err.Description, , "Error"  
    End If  
End Sub  
' EndCreateViewVB  

Vedere anche

Proprietà ActiveConnection (ADOX)
Metodo Append (raccolta Views ADOX)
Oggetto Catalog (ADOX)
Oggetto View (ADOX)
Raccolta Views (ADOX)