Stored Proc

  • Hi,

    I want to execute a stored procedure by having an output parameter. Can any one tell me what is wrong in the below code

    sQuery = "exec usp_test a1 OUTPUT"

    gObjConn.Execute sQuery

    Response.write a1

    I want to get the output parameter from the SQL server and print it out in asp page.

    Thanks,

    Anu

  • You will need to use an ADO Command object and set the parameters...or change the stored procedure to SELECT the output variable into a dataset.

    Guarddata-

  • Guarddata is correct. Your code will look like this:

    set cmd = server.CreateObject("ADODB.Command")

    with cmd

    .ActiveConnection = gObjConn

    .CommandType = adCmdStoredProc

    .CommandText = "usp_test"

    .Parameters.Append .CreateParameter("a1", <type>, adParamOutput, )

    .Execute

    a1 = .Parameters("a1")

    .ActiveConnection = nothing

    end with

    set cmd = nothing

    Response.Write(a1)

    Of course, you would need to define the ADO constants by including ADOVBS.inc or copy and paste the appropriate values into the script.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply