Submitted By: Kent Finkle

Creates a stored procedure named ChangeDate in a Microsoft Access database.

Visual Basic
Edit|Remove
Option Explicit
'*  Script name:    CreateProcedure.vbs
'*  Created on:     Monday, June 18, 2007
'*  Author:         Kent Finkle
'*  Purpose:        Create a stored procedure in an Access database.
 
Dim objCatalog
Dim objCommand
 
Set objCatalog = CreateObject("ADOX.Catalog")

Set objCommand = CreateObject("ADODB.Command")
 
objCatalog.ActiveConnection = _
        "Provider = Microsoft.Jet.OLEDB.4.0; " & _
            "Data Source = c:\scripts\test.mdb"
 
objCommand.CommandText = "PARAMETERS [Dt] Date;" & _
        "UPDATE Hardware SET Hardware.Dt = [Dt] " _
 & " WHERE Hardware.Location='LA'; "
 
objCatalog.Procedures.Append "ChangeDate", objCommand