The following code demonstrates how to use a Command object and the Procedures collection Append method to create a new procedure in the underlying data source.
' BeginCreateProcedureVB Sub CreateProcedure() Dim cnn As New ADODB.Connection Dim cmd As New ADODB.Command Dim prm As ADODB.Parameter Dim cat As New ADOX.Catalog ' Open the Connection cnn.Open _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=c:\Program Files\Microsoft Office\" & _ "Office\Samples\Northwind.mdb;" ' Create the parameterized command (Microsoft Jet specific) Set cmd.ActiveConnection = cnn cmd.CommandText = "PARAMETERS [CustId] Text;" & _ "Select * From Customers Where CustomerId = [CustId]" ' Open the Catalog Set cat.ActiveConnection = cnn ' Create the new Procedure cat.Procedures.Append "CustomerById", cmd End Sub ' EndCreateProcedureVB
ActiveConnection Property | Append Method (Procedures) | Catalog Object | Procedure Object | Procedures Collection
© 1998-2001 Microsoft Corporation. All rights reserved.