Creating Stored Procedure error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lauren Quantrell

    #1

    Creating Stored Procedure error

    Trying to create a new stored procedure from code, running the code
    below I just cut and pasted directly from the MS Knowledge Base, I get
    the following error message:

    Line 1: Incorrect syntax near 'prmCity'

    Any ideas?
    lq


    Code:

    Public Function CreateProc()

    Dim strProc As String

    strProc = "Create Procedure qryCustByCity " & _
    "(prmCity varchar) as " & _
    "select * from Customers where City = prmCity"

    CurrentProject. Connection.Exec ute strProc

    End Function
  • Tom van Stiphout

    #2
    Re: Creating Stored Procedure error

    On 30 Oct 2003 14:18:53 -0800, laurenquantrell @hotmail.com (Lauren
    Quantrell) wrote:

    You forgot the @ sign. Try this:
    strProc = "Create Procedure qryCustByCity " & _
    "(@prmCity varchar) as " & _
    "select * from Customers where City = @prmCity"

    Note that an alternative to creating procedures on the fly is to send
    the statement to a sproc that uses EXECUTE to run the passed in
    statement.

    -Tom.

    [color=blue]
    >Trying to create a new stored procedure from code, running the code
    >below I just cut and pasted directly from the MS Knowledge Base, I get
    >the following error message:
    >
    > Line 1: Incorrect syntax near 'prmCity'
    >
    >Any ideas?
    >lq
    >
    >
    >Code:
    >
    >Public Function CreateProc()
    >
    > Dim strProc As String
    >
    > strProc = "Create Procedure qryCustByCity " & _
    > "(prmCity varchar) as " & _
    > "select * from Customers where City = prmCity"
    >
    > CurrentProject. Connection.Exec ute strProc
    >
    >End Function[/color]

    Comment

    Working...