Retrieving stored procedure output parameter via ADO

后端 未结 3 1402
有刺的猬
有刺的猬 2021-01-19 22:07

I\'m stuck with this for more than 48 Hrs now. I\'m trying to retrieve a output parameter value using ADO objects. here is my vba code.

Function ExecuteComm         


        
相关标签:
3条回答
  • 2021-01-19 22:43

    Have a try after removing SET NOCOUNT ON; from your procedure

    I think this will help you. The affected row count will not returned if you set SET NOCOUNT ON; in procedure.

    0 讨论(0)
  • 2021-01-19 22:59

    If you are not expecting a recordset as part of your stored procedure call, use cmd1->Execute(NULL, NULL, ADO::adExecuteNoRecords);

    0 讨论(0)
  • 2021-01-19 23:05

    This is probably because, as Technet says, In the case of output parameters and return values, the values are not returned until the data of the Recordset object has been fetched completely or the Recordset has been closed.

    Either close your RecordSet (rds.Close), if you're not interested in the data returned by the SELECT statement, or loop through it until you've read all rows.

    As an aside, if you are never interested in the data returned by the select statement, only the row count, then it's more efficient not to return it. So if you can modify your SP, you could change it to:

    SELECT @returnval = COUNT(*) FROM type_table WHERE type1=@para1 and type2=@para2 and type3=@para3
    
    0 讨论(0)
提交回复
热议问题