你这个什么呀
@percentage的付值在哪里呀
Set objRS = objCmd.Execute() 
在这里不能写
只能写
objCmd.Execute 

解决方案 »

  1.   

    如果要用存储过程返回记录集的话,这样就行了set rs=cnn.execute("存储过程名 参数")
      

  2.   

    你的代碼本來沒有任何的問題
    原因出在Const strIn = 30 行
    objCmd.CommandText = "byroyalty" 行
    後面都有不明的空格字符所導致
    不信你可以刪除它們再試試或則拷貝以下代碼:<% @LANGUAGE = VBScript %> 
    <!--#include file="adovbs.inc"--> 
    <% 
    Response.Expires = 0 
    Dim Cnn, objRS,strConn,objCmd, objParam 
    Const strIn = 30
    Set Cnn = Server.CreateObject("ADODB.Connection") 
    strConn ="driver={SQL Server};server=sun;database=pubs;uid=sa;pwd=thesun" 
    Cnn.Open strConn 
    Set objCmd = Server.CreateObject("ADODB.Command") 
    objCmd.CommandText = "byroyalty"
    objCmd.CommandType = adCmdStoredProc
    Set objCmd.ActiveConnection = Cnn 
    Set objParam = objCmd.CreateParameter ("@percentage", adInteger, adParamInput, 4, strIn) 
    objCmd.Parameters.Append objParam 
    Set objRS = objCmd.Execute() 
    %> 
    <HTML> 
    <BODY> 
    <%= objCmd.Parameters("@percentage") %> . 
    <BR><BR> au_id<Br> 
    <% 
    While Not objRS.EOF 
    Response.Write Server.HTMLEncode(objRS("au_id")) & "<Br>" 
    objRS.MoveNext 
    Wend 
    objRS.close: Cnn.close 
    Set objRS = Nothing: Set Cnn = Nothing 
    Set objParam = Nothing: Set objCmd = Nothing 
    %> 
    </BODY> 
    </HTML>