用command对象或者是recordset对象就搞定了

解决方案 »

  1.   

    procedure  p_getZiJinTongJi
             @GongChengxmid int,  --- 工程项目ID 
             @RiQi_1 datetime,    --- 起始时间 
             @RiQi_2 datetime     --- 截止时间 可以给点代码吗?
    真的不是很懂这个!
      

  2.   

    更加怪的问题.
    以前直接写的链接存储过程的代码现在也报错了.
    代码如下:
    <?php
    $dbhost="192.168.1.101";
    $dbuser="sa";
    $dbpasswd="";
    $dbname="tcms_yc";
    $conn=NULL;
    $stmt=NULL;
    $rs=NULL;
    $conn = @mssql_connect($dbhost,$dbuser,$dbpasswd) or die("无法连接数据库服务器!");
    mssql_select_db($dbname,$conn) or die("无法连接数据库!");
    $stmt = mssql_init("p_getJianYanJieGuo",$conn) or die("视图不存在!");
    mssql_bind($stmt, "@jianyanid",1,SQLINT4); 
    $rs = mssql_execute($stmt, false);
    do {
    while ($row = mssql_fetch_array($rs)) {
    echo "<PRE>";
    print_r($row);
    echo "</PRE>";
    }
    } while (mssql_next_result($rs));
    ?>
    老提示:
    mssql_bind($stmt, "@jianyanid",1,SQLINT4); 
    这行出错.
    出错提示如下:
    Fatal error: Only variables can be passed by reference in c:\inetpub\wwwroot\yczjz\mssql.php on line 19我就算在页面输入任何东西,都不显示,还是报那行出错.
      

  3.   

    $dbc = new COM("ADODB.Connection");
    $dbc->Provider = "sqloledb";
    $dbc->Open('DSN=starmate;Database=magway;UID=sa;PWD='); //这个就是连接字符串,我没写过php不过一样很简单
    $q="p_getZiJinTongJi";//存储过程名$cm= new COM("ADODB.Command");
    $cm->CommandText=$q;
    $cm->ActiveConnection=$dbc; //PropPut() failed!!!
    $rs=$cm->Execute();不好意思啊,我还转到asp的adodb的应用,其实都差不多,其中一些代码,我木写过php,大概能理解...sorry了Set cmdTest = Server.CreateObject("ADODB.Command")cmdTest.CommandText = "byroyalty"          ''存储过程名''设命令类型为 存储过程cmdTest.CommandType = adCmdStoredProc ''创建 Parameter 对象Set prmTest = Server.CreateObject("ADODB.Parameter")‘Type属性对应wuf70.asp中的第二个参数prmTest.Type = adInteger        ''4 字节的带符号整型‘Direction属性对应wuf70.asp中的第三个参数prmTest.Direction = adParamInput‘Value属性对应wuf70.asp中的第五个参数prmTest.Value = 30cmdTest.Parameters.Append prmTest Set cmdTest.ActiveConnection = Cnn‘需要返回一个记录集,故使用Set rsTest = cmdTest.ExecuteSet rsTest = cmdTest.Execute写法大概都差不多,只要中间的样子改改,还有,参数需要是数字值就可以了
      

  4.   

    liuxiaoyi666,谢谢你了,呵呵,asp的我看的懂.
    昨天php的也搞定了.很郁闷.
    问题就在于
    mssql_bind($stmt, "@jianyanid",1,SQLINT4); 
    这个1必须是变量才行.折腾了很久.我现在想知道的就是php使用adodb数据库操作类的时候怎么使用存储过程.
      

  5.   

    ADODB数据类型,在向mssql的存储过程传参时要指定参数数据类型
    希望对你有用。
    ---- DataTypeEnum Values ----数据类型
    Const adEmpty = 0
    Const adTinyInt = 16
    Const adSmallInt = 2
    Const adInteger = 3
    Const adBigInt = 20
    Const adUnsignedTinyInt = 17
    Const adUnsignedSmallInt = 18
    Const adUnsignedInt = 19
    Const adUnsignedBigInt = 21
    Const adSingle = 4
    Const adDouble = 5
    Const adCurrency = 6
    Const adDecimal = 14
    Const adNumeric = 131
    Const adBoolean = 11
    Const adError = 10
    Const adUserDefined = 132
    Const adVariant = 12
    Const adIDispatch = 9
    Const adIUnknown = 13
    Const adGUID = 72
    Const adDate = 7
    Const adDBDate = 133
    Const adDBTime = 134
    Const adDBTimeStamp = 135
    Const adBSTR = 8
    Const adChar = 129
    Const adVarChar = 200
    Const adLongVarChar = 201
    Const adWChar = 130
    Const adVarWChar = 202
    Const adLongVarWChar = 203
    Const adBinary = 128
    Const adVarBinary = 204
    Const adLongVarBinary = 205