--- title: "Append and CreateParameter Methods Example (JScript) | Microsoft Docs" ms.prod: sql ms.prod_service: connectivity ms.technology: connectivity ms.custom: "" ms.date: "01/19/2017" ms.reviewer: "" ms.topic: conceptual dev_langs: - "JScript" helpviewer_keywords: - "CreateParameter method [ADO], JScript example" - "Append method [ADO], JScript example" ms.assetid: 37000833-68f4-45f1-b2dd-7f75893d09d9 author: MightyPen ms.author: genemi --- # Append and CreateParameter Methods Example (JScript) This example uses the [Append](../../../ado/reference/ado-api/append-method-ado.md) and [CreateParameter](../../../ado/reference/ado-api/createparameter-method-ado.md) methods to execute a stored procedure with an input parameter. Cut and paste the following code to Notepad or another text editor, and save it as **AppendJS.asp**. ``` <%@LANGUAGE="JScript" %> <%// use this meta tag instead of adojavas.inc%> Append and CreateParameter Methods Example (JScript)

Append and CreateParameter Methods Example (JScript)

<% // verify user-input var iRoyalty = parseInt(Request.Form("RoyaltyValue")); if (iRoyalty > -1) { // connection, recordset and command variables var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" + "Initial Catalog='pubs';Integrated Security='SSPI';"; var Cnxn = Server.CreateObject("ADODB.Connection"); var cmdByRoyalty = Server.CreateObject("ADODB.Command"); var rsByRoyalty = Server.CreateObject("ADODB.Recordset"); var rsAuthor = Server.CreateObject("ADODB.Recordset"); // display variables var strMessage; try { // open connection and set cursor location Cnxn.Open(strCnxn); Cnxn.CursorLocation = adUseClient; // command object initial parameters cmdByRoyalty.CommandText = "byroyalty"; cmdByRoyalty.CommandType = adCmdStoredProc; // create the new parameter and append to // the Command object's parameters collection var prmByRoyalty = cmdByRoyalty.CreateParameter("percentage", adInteger, adParamInput); cmdByRoyalty.Parameters.Append(prmByRoyalty); prmByRoyalty.Value = iRoyalty; cmdByRoyalty.ActiveConnection = Cnxn; // execute command rsByRoyalty = cmdByRoyalty.Execute(); // display results rsAuthor.Open("Authors", Cnxn); while (!rsByRoyalty.EOF) { rsAuthor.Filter = "au_id='" + rsByRoyalty.Fields("au_id") + "'"; // start new line strMessage = "

"; // recordset data strMessage += rsAuthor.Fields("au_fname") + " "; strMessage += rsAuthor.Fields("au_lname") + " "; // end the line strMessage += "

"; // show result Response.Write(strMessage); // et next record rsByRoyalty.MoveNext; } } catch (e) { Response.Write(e.message); } finally { // clean up if (rsByRoyalty.State == adStateOpen) rsByRoyalty.Close; if (rsAuthor.State == adStateOpen) rsAuthor.Close; if (Cnxn.State == adStateOpen) Cnxn.Close; rsByRoyalty = null; rsAuthor = null; Cnxn = null; } } %>

Enter royalty percentage to find (e.g., 40):

``` ## See Also [Append Method (ADO)](../../../ado/reference/ado-api/append-method-ado.md) [CreateParameter Method (ADO)](../../../ado/reference/ado-api/createparameter-method-ado.md) [Field Object](../../../ado/reference/ado-api/field-object.md) [Fields Collection (ADO)](../../../ado/reference/ado-api/fields-collection-ado.md) [Parameter Object](../../../ado/reference/ado-api/parameter-object.md)