本文介绍了即使 sqlsrv_query 没有错误,存储过程也无法获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 2 个参数的存储过程.我可以使用下面相同的脚本执行带有一个参数的存储过程.但是我无法使用两个参数使其工作.

I have a stored procedure with 2 parameters. I'm able to execute stored procedures with one parameter using the same script below. But I couldn't make it work with two parameters.

$stmt = "{CALL VM_GETPRs_CAMPS (?,?)}";**//SP has 160 rows of data.**

$fdate=date("Y-m-d");
$tdate=date("Y-m-d");

$params = array(
                 array($fdate,SQLSRV_PARAM_IN),
                 array($tdate,SQLSRV_PARAM_IN)
               );

$result = sqlsrv_query( $conn, $stmt,$params,array('Scrollable' => 'buffered'));   //not getting any error

if( $result === false) {
    die( print_r( sqlsrv_errors(), true) );
} else{
    **//**I tried sqlsrv_num_rows and sqlsrv_has_rows both are giving zero rows.**
    $row_count = sqlsrv_num_rows( $result );
    if ($row_count === false)
        echo "No rows";
    else if ($row_count >=0)
      echo "\n$row_count\n";

if(sqlsrv_has_rows($result))
    echo "has rows";
else
    echo "No rows";
exit();

这两天我一直在寻找解决方案.请帮帮我.

I'm looking for a solution since two days. Please help me.

推荐答案

你可以试试

"execute VM_GETPRs_CAMPS ?,?"

此外,如果您的存储过程中有任何 PRINT 语句可能会导致一些麻烦

Also if you have any PRINT statement on your stored procedure may cause some trouble

这篇关于即使 sqlsrv_query 没有错误,存储过程也无法获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 07:32