Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to pass datetime paramter form ASP to stored procedure

    The ASP code I have looks like this:
    strDate = "2005-09-19"
    rs.Open "my_proc " & cdate(strDate) , conn


    In the stored procedure I would like to do something like:

    CREATE PROCEDURE my_Proc
    @DateStamp DateTime
    AS
    EXEC('SELECT * FROM tableName WHERE TimeStamp > '+ @DateStamp)


    Obviously this doesn't work. I am getting an error like:
    Error Type:
    Microsoft OLE DB Provider for SQL Server (0x80040E14)
    Line 1: Incorrect syntax near '/'.

    Can you show me how to pass datetime from ASP to stored procedure to populate a record set?

  • #2
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you sure your stored Proc is formated correctly and runs in SQL Server? I would check this out first, before thinking it is a calling error with in your ASP code.

    Below is how you can set Parameters for stored procs in ASP:

    dim objCmd
    Set objCmd = server.CreateObject("ADODB.Command")
    objCmd.CommandType = adCmdstoredProc
    objCmd.ActiveConnection = oConn
    objCmd.CommandText = "storedProcName"

    dim objParam
    Set objParam = objCmd.CreateParameter("@ProcParamter",adVarChar,adParamInput,10,ValueToBePassedIn)

    objCmd.Parameters.Append objParam


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •