Sunday, February 19, 2012

Help: Append Parameters in ASP classic

Hi,

Please tell me what is wrong in the following code to get the RecordSet by calling the Stored Procedure.

'==============================================
Dim StaffRS, objComm, objParam1, objParam2, objParam3

'Set RecordSet, ADODB.Command
Set StaffRs = Server.CreateObject("ADODB.RECORDSET")
Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = conn 'conn was set earler
objComm.CommandText = "GetStaffReport" 'Stored Procedure
objComm.CommandType = adCmdStoredProc '**Error line**

'Append Parameters
set objParam1 = objcomm.CreateParameter ("People_ID", adVarChar, adParamInput, "123")
objComm.Parameters.Append objparam1
set objparam2 = objcomm.CreateParameter ("DateLow", adDate, adParamInput, 02/02/2006)
objComm.Parameters.Append objparam2
set objparam3 = objcomm.CreateParameter ("DateHigh", adDate, adParamInput, 02/15/2006)
objComm.Parameters.Append objparam3

set StaffRS = objComm.Execute
'Close up work...
'============================================

The Stored Procedure is:
'********************************************
CREATE PROCEDURE GetStaffReport
(@.People_ID varchar(32), @.Weeklow datetime, @.Weekhigh datetime)

AS

SELECT * FROM view_People WHERE
Main_People = @.People_ID AND Main_Ending >= @.WeekLow AND Main_Ending <= @.Weekhigh
Order by Main_Ending DESC

RETURN
GO
'*********************************************

Everything looks correct, but I got an error:
ADODB.Command error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/folder/folder/file.asp, line (**Error line**)

Please give me any information about this error, and how to correct it.

Thank you.

Looking at your code

set objParam1 = objcomm.CreateParameter ("People_ID", adVarChar, adParamInput, "123")
objComm.Parameters.Append objparam1
set objparam2 = objcomm.CreateParameter ("DateLow", adDate, adParamInput, "02/02/2006")
objComm.Parameters.Append objparam2
set objparam3 = objcomm.CreateParameter ("DateHigh", adDate, adParamInput, "02/15/2006")
objComm.Parameters.Append objparam3

Won't you qoute two parameter values listed above? Without quotes you pass 02 divided by 02 divided by 2006 (very small number) as a value for datetime.

WBR, Evergray
--
Words mean nothing...

|||

Thank you, WBR,

Actually, the "02/02/2006" is what I put here in the forum, there is a real parameter Week1 with a gaven format: Week1= FormatDateTime (WeekEndingLow,2), which is 2/02/2006. The "02/15/2006" is the same way. So the lines in my real code is:

set objParam1 = objcomm.CreateParameter ("People_ID", adVarChar, adParamInput, Staff_ID)
objComm.Parameters.Append objparam1

set objparam2 = objcomm.CreateParameter ("DateLow", adDate, adParamInput, Week1)objComm.Parameters.Append objparam2
set objparam3 = objcomm.CreateParameter ("DateLow", adDate, adParamInput, Week2)objComm.Parameters.Append objparam3

But it still has the error:"800a0bb9"

By the way, the stored procedure I called is reading the data from a view:

"SELECT * FROM view_People" the view_People is a view, not a table, I don't know if this is a problem.

Thank you for your help.

|||

maybe you should do this;

objComm.CommandType = adCmdStoredProc '**Error line**
objComm.CommandType = 4

good luck

No comments:

Post a Comment