来源:www.cncfan.com | 2006-1-11 | (有2106人读过)
在我的上一篇文章里,我谈了用php调用一个不带参数的存贮过程,那php可不可以调用带参数的存贮过程吗?答案是:当然可以! 请看我的例子 带参数的存贮过程: CREATE PROCEDURE sp_mystore @myInput int AS Select companyname, contactname, postalcode From customers Where postalcode = @myInput
我的php文件 <? #myInt = 1010; define ("OLEDB_CONNECTION_STRING", "Provider=SQLOLEDB; Data Source=zzb; Initial Catalog=Northwind; User ID=sa; Password="); $dbc = new COM("ADODB.Connection"); $dbc->Open(OLEDB_CONNECTION_STRING); $command = "sp_mystore"." ".$myInt; //echo $command; $rs = $dbc->Execute($command); // Recordset //echo "$rs; $i = 0;
echo '<table cellSpacing="1" cellPadding="3" width="600" align="center" bgColor="#000000" border="0"> <tr vAlign="bottom" bgColor="#9999cc"> <th>Directive</th> <th>Local Value</th> <th>Master Value</th> </tr>';
while (!$rs->EOF) { $i += 1; $fld0 = $rs->Fields(0); $fld1 = $rs->Fields(1); $fld2 = $rs->Fields(2); print '<tr vAlign="baseline" bgColor="#cccccc"> <td bgColor="#ccccff"><b>'; print $fld0->value; print '</b> </td> <td align="middle">'; print $fld1->value; print '</td><td align="middle">'; print $fld2->value; print '</td></tr>';
$rs->MoveNext(); } print '</TABLE>';
$rs->Close(); ?>
结果是,当然ok了,我只是利用ado中的一个部分,还可以用它的其它部分,我也打算试一下,如果成功的话,愿意和大家分享!
我要对大家说得是:php是你不错的选择!
|