Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 3.50 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-23-2005, 05:40 PM   PM User | #1
techzone12
New to the CF scene

 
Join Date: Sep 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
techzone12 is an unknown quantity at this point
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?
techzone12 is offline   Reply With Quote
Old 09-23-2005, 07:48 PM   PM User | #2
mRW1Zard
New to the CF scene

 
Join Date: Sep 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
mRW1Zard is an unknown quantity at this point
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
mRW1Zard is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:23 PM.


Advertisement
Log in to turn off these ads.