--- title: "Execute, Requery, and Clear 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: - "Requery method [ADO], JScript example" - "Clear method [ADO], JScript example" - "Execute method [ADO], JScript example" ms.assetid: 51a87e91-c9d9-4e49-af47-79cce2c4cfe0 author: MightyPen ms.author: genemi --- # Execute, Requery, and Clear Methods Example (JScript) This example demonstrates the **Execute** method when run from both a [Command](../../../ado/reference/ado-api/command-object-ado.md) object and a [Connection](../../../ado/reference/ado-api/connection-object-ado.md) object. It also uses the [Requery](../../../ado/reference/ado-api/requery-method.md) method to retrieve current data in a [Recordset](../../../ado/reference/ado-api/recordset-object-ado.md), and the [Clear](../../../ado/reference/ado-api/clear-method-ado.md) method to clear the contents of the [Errors](../../../ado/reference/ado-api/errors-collection-ado.md) collection. (The **Errors** collection is accessed via the **Connection** object of the [ActiveConnection](../../../ado/reference/ado-api/activeconnection-property-ado.md) property of the [Recordset](../../../ado/reference/ado-api/recordset-object-ado.md).) Name the file **ExecuteJS.asp**. ``` <%@LANGUAGE="JScript"%> <%// use this meta tag instead of adojavas.inc%> <% strLastName = new String(Request.Form("AuthorLName")); if (strLastName.indexOf("undefined") > -1) strLastName = ""; %>
";
strMessage += "
";
// recordset data
strMessage += rsAuthor("au_fname") + " ";
strMessage += rsAuthor("au_lname") + " ";
// end the line
strMessage += "
"; // first and last name are in first column strMessage2 += rsAuthor2("au_fname") + " " strMessage2 += rsAuthor2("au_lname") + " "; // end the line strMessage2 += "
"; // show results Response.Write(strMessage2); // get next record rsAuthor2.MoveNext; } } catch (e) { Response.Write(e.message); } finally { // clean up if (rsAuthor.State == adStateOpen) rsAuthor.Close; if (rsAuthor2.State == adStateOpen) rsAuthor2.Close; if (Cnxn.State == adStateOpen) Cnxn.Close; rsAuthor1 = null; rsAuthor2 = null; Cnxn = null; } } %>