Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help on simple stored proc calling

Status
Not open for further replies.

Abs2017

Programmer
May 18, 2017
3
0
0
US
Hello,

I am new at this forum. It's been years since I did classic ASP. I need help with call stored proc.


Stored proc "usp_Stipend_Check_Status"
@record_number​
@new_status_id​
@comment optional​
@rejection_reason_id​

my code
Code:
Function Submit_usp_Stipend_Check_Status(RecNum, new_status_id, comment, recjReason)
    on error resume next

    Const adCmdStoredProc = 4
    Set cmd = Server.CreateObject("ADODB.Command") 
    if cmd.State <> adStateOpen then Set cmd.ActiveConnection = conn   'conn  'connTest
    cmd.CommandText = "usp_Stipend_Check_Status"

    cmd.CommandType = adCmdStoredProc 'adOpenStatic
    cmd.Parameters("@record_number") = RecNum   'CODE DOESN'T EXECUTE PASS THIS POINT
    cmd.Parameters("@new_status_id") = new_status_id
    if len(comment) <> 0 then cmd.Parameters("@comment") = comment
    if len(recjReason) <> 0 then cmd.Parameters("@rejection_reason_id") = recjReason
    Submit_usp_Stipend_Check_Status = cmd.Execute()
	Set cmd = Nothing 
    LogFile = LogToFile("Call usp_Stipend_Check_Status " & RecNum & ", " & new_status_id)   
    if Err.number > 0 then
        LogToFile(Err.number & ". " & Err.Description)
        Err.Clear
    end if  
    on Error goto 0
End Function


 
Remove the "on error resume next" so you can see what the error is, and on which line.
 
Guitarzan,

Thank you for responding. I turned off the friendly error message. It returned " Item cannot be found in the collection....bla bla". It seems that it doesn't recognize parameter "@record_number". But all datatype and spelling are correct. It's mysterious to me. Any thought?
 
Don't you need to add the parameters to the command before you can access them?
 
Abs 2017 said:
Code:
if cmd.State <> adStateOpen then Set cmd.ActiveConnection =  [highlight #FCE94F]conn[/highlight]

Where do you define conn
 
DaveInIowa is correct on this issue. Thank everyone for helping. Special thanks to Dave. Have a great weekend,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top