经典ASP从href执行存储过程

时间:2011-03-15 17:54:31

标签: asp-classic

我有一个index.asp页面,显示来自SQL 2005 DB的数据。在该索引页面上,我有一个已经在下拉菜单中选择了用户的课程。我想打开一个新页面test-results.asp,它显示了他们点击课程标题所做的实际测试。我的存储过程spGetCourseResultsByID使用以下参数@MedLicID,@ TestID检索数据。我不知道该怎么做。我之前从未支持过经典的asp。

1 个答案:

答案 0 :(得分:0)

这有点宽泛,因为我们对链接或存储过程一无所知。

  1. 使用request.querystring检索链接参数的值(如果有)。
  2. 2。 使用ADO命令对象将参数传递给存储过程 这是一个示例,但需要针对实际存储过程进行修改

     Function GetTest()
        Dim cmd, cn
        Set cmd = Server.CreateObject("ADODB.Command")
        Set cmd.ActiveConnection = dbconn
        With cmd
            .CommandText = "spGetCourseResultsByID"
            .Parameters.Append  .CreateParameter("@RETURN_VALUE", adInteger, adParamReturnValue)
            .Parameters.Append  .CreateParameter("@MedLicID", adVarChar, adParamInput,50,MedLic_ID)
            .Parameters.Append  .CreateParameter("@TestID", adVarChar, adParamInput,50,Test_ID)
            .execute
            strResponse = Cint(.Parameters(0).value )
        End With
        With Response
            if strResponse > 0 then
                .Write strSuccess
            else
                .Write strFailure
            end if
        End With
    End Function
    
相关问题