使用adodb如何操作存储过程? 用command对象或者是recordset对象就搞定了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 procedure p_getZiJinTongJi @GongChengxmid int, --- 工程项目ID @RiQi_1 datetime, --- 起始时间 @RiQi_2 datetime --- 截止时间 可以给点代码吗?真的不是很懂这个! 更加怪的问题.以前直接写的链接存储过程的代码现在也报错了.代码如下:<?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我就算在页面输入任何东西,都不显示,还是报那行出错. $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写法大概都差不多,只要中间的样子改改,还有,参数需要是数字值就可以了 liuxiaoyi666,谢谢你了,呵呵,asp的我看的懂.昨天php的也搞定了.很郁闷.问题就在于mssql_bind($stmt, "@jianyanid",1,SQLINT4); 这个1必须是变量才行.折腾了很久.我现在想知道的就是php使用adodb数据库操作类的时候怎么使用存储过程. ADODB数据类型,在向mssql的存储过程传参时要指定参数数据类型希望对你有用。---- DataTypeEnum Values ----数据类型Const adEmpty = 0Const adTinyInt = 16Const adSmallInt = 2Const adInteger = 3Const adBigInt = 20Const adUnsignedTinyInt = 17Const adUnsignedSmallInt = 18Const adUnsignedInt = 19Const adUnsignedBigInt = 21Const adSingle = 4Const adDouble = 5Const adCurrency = 6Const adDecimal = 14Const adNumeric = 131Const adBoolean = 11Const adError = 10Const adUserDefined = 132Const adVariant = 12Const adIDispatch = 9Const adIUnknown = 13Const adGUID = 72Const adDate = 7Const adDBDate = 133Const adDBTime = 134Const adDBTimeStamp = 135Const adBSTR = 8Const adChar = 129Const adVarChar = 200Const adLongVarChar = 201Const adWChar = 130Const adVarWChar = 202Const adLongVarWChar = 203Const adBinary = 128Const adVarBinary = 204Const adLongVarBinary = 205 如何让自己的电脑发布网站 求助:网页显示方面的问题 如何刷新页面 各位大侠,本人php新手,能给我推荐些关于php的书吗,谢谢 smarty 为什么只有ansi编码的? smarty显示的问题 smartTemplate php里new一个对象后用不用delete? 我人品有问题么?散分 还是PHP+MYSQL的问题,请大家帮帮忙。急死了! 一个表单的问题 救命!网站老是被软件注入大量垃圾信息!!!
@GongChengxmid int, --- 工程项目ID
@RiQi_1 datetime, --- 起始时间
@RiQi_2 datetime --- 截止时间 可以给点代码吗?
真的不是很懂这个!
以前直接写的链接存储过程的代码现在也报错了.
代码如下:
<?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我就算在页面输入任何东西,都不显示,还是报那行出错.
$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写法大概都差不多,只要中间的样子改改,还有,参数需要是数字值就可以了
昨天php的也搞定了.很郁闷.
问题就在于
mssql_bind($stmt, "@jianyanid",1,SQLINT4);
这个1必须是变量才行.折腾了很久.我现在想知道的就是php使用adodb数据库操作类的时候怎么使用存储过程.
希望对你有用。
---- 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