Error trying to call stored procedure with prepared statement

后端 未结 2 479
一个人的身影
一个人的身影 2020-12-02 02:49

I\'m trying to use a prepared statement to call a stored procedure (using ADODB with classic ASP), but when I set CommandType I get the following error:

2条回答
  •  醉梦人生
    2020-12-02 03:28

    Here is how you call a stored procedure in ASP classic:

    'Set the connection
    '...............
    
    'Set the command
    DIM cmd
    SET cmd = Server.CreateObject("ADODB.Command")
    SET cmd.ActiveConnection = Connection
    
    'Set the record set
    DIM RS
    SET RS = Server.CreateObject("ADODB.recordset")
    
    'Prepare the stored procedure
    cmd.CommandText = "procName"
    cmd.CommandType = 4  'adCmdStoredProc
    
    'Assign value to the parameter
    cmd.Parameters("@ParamName ") = ParamValue 
    
    'Execute the stored procedure
    RS = cmd.Execute
    SET cmd = Nothing
    
    'You can now access the record set
    if (not RS.EOF) THEN
        data = RS("column_name")
    end if
    
    'dispose your objects
    RS.Close
    SET RS = Nothing
    
    Connection.Close
    SET Connection = Nothing
    

提交回复
热议问题