Call SQL Stored Procedure from ASP

  • Hi friends, i want to call a SP from ASP (not dot net) that returns some many rows.

    The conn string is:

    <%

        Set objCon = CreateObject("ADODB.Connection")

        Set objRS = CreateObject("ADODB.Recordset")

        objcon.connectionstring = "Provider=SQLOLEDB.1;User ID=USER;Password=XXXX;Persist Security Info=True;Initial Catalog=opessa;Data Source=SERVER01"   

        iCursorType                = 1

        iLockType                = 3

        objCon.Open

        %>

    Then i use the following sentence to call the SP from ASP

     SQLtxt = "exec SPNAME '" & PARAM1 & "','" & PARAM2 & "','" & PARAM3 & "'"  objRS.open SQLTXT, objcon

    And last, i try to print the results:

     WHILE NOT ObjRS.EOF

               Response.Write "

    " & ObjRS("XXXXX").VALUE & "" & ObjRS("XXXXX").VALUE & "" & ObjRS("XXXXX").VALUE & " Mb" & "" & ObjRS("XXXXX").VALUE & " Mb" & "" & ObjRS("XXXXX").VALUE & " %" & "

    "

    ObjRS.Movenext

    WEND

    ObjRS.CLOSE

    But i receive the following error:

    ADODB.Recordset error '800a0e78'

    Operation is not allowed when the object is closed.

    Whats wrong??? Anyone can help me?

    Thanks in advance.

     

     

  • I have a cursor inside the SP.

  • I have a cursor inside the SP.

  • I have a cursor inside the SP.

  • I would use the ADO Command object to call your stored procedure.

    I don't have my ADO books to hand but it is a case of setting

    Command.CommandText to the name of your stored procedure.

    Command.CommandType to the value of adStoredProcedure

    Command.ReturnsRecords to an appropriate setting.

    Appending parameters to the Command object, then Command.Execute.

    There are plenty of examples still available on the net such as http://www.developerfusion.co.uk/show/2270/

Viewing 5 posts - 1 through 4 (of 4 total)

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