Stored procedure resources

Results 1 to 2 of 2

Thread: Stored procedure resources

  1. #1
    Join Date
    Dec 1969

    Default Stored procedure resources

    Can any one point me in the direction of a good resource / page for passing asp parameters to a stored procedure? or an example?<BR><BR>Cheerz

  2. #2
    Garth Guest

    Default RE: Stored procedure resources

    The code shown below demonstrates two methods for calling a stored procedure with a single parameter. The example is based on the Customers table in the Northwind database. Create the procedure in Northwind, modify the connection string, and then run the ASP. <BR><BR>Let me know if you need an example that works with an OUTPUT parameter.<BR><BR>Garth<BR><BR><BR> !--<BR> DDL<BR> CREATE PROCEDURE ps_Customers_ByCompanyName<BR> @CompanyName nvarchar(40)<BR> AS<BR> SELECT CustomerID,<BR> CompanyName<BR> FROM Customers<BR> WHERE CompanyName LIKE @CompanyName+&#039%&#039<BR>--&#062;<BR><BR><BR>&#060;!--#include file=""--&#062;<BR>&#060;%<BR> CompanyName = "a"<BR><BR><BR> Set objConn = server.CreateObject("ADODB.Connection")<BR> REM DSN-Less OLE-DB<BR> objConn.Open "Provider=SQLOLEDB;Server=ACE;Database=Northwind;U id=sa;Pwd="<BR><BR><BR> REM ADO Command Object<BR> Set cmd1 = server.CreateObject("ADODB.Command")<BR> cmd1.ActiveConnection = objConn<BR> cmd1.CommandType = adCmdStoredProc<BR> cmd1.CommandText = "ps_Customers_ByCompanyName"<BR> cmd1.Parameters.Append cmd1.CreateParameter("CompanyName",adVarChar,adPar amInput,40,CompanyName)<BR> set rs1 = cmd1.Execute<BR><BR> response.write rs1("CustomerID") & " " & rs1("CompanyName") <BR><BR><BR><BR> REM String/Execute<BR> sSQL = "ps_Customers_ByCompanyName &#039" & CompanyName & "&#039"<BR> set rs2 = objConn.Execute(sSQL)<BR><BR> response.write rs2("CustomerID") & " " & rs2("CompanyName")<BR><BR><BR><BR> objConn.Close<BR>%&#062;<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts