--- title: "Execute, Requery, and Clear Methods Example (VBScript) | 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: - "VB" helpviewer_keywords: - "Execute method [ADO], VBScript example" - "Clear method [ADO], VBScript example" - "Requery method [ADO], VBScript example" ms.assetid: 3a7bbf07-2fca-4892-95f4-eec93f2d5e91 author: MightyPen ms.author: genemi --- # Execute, Requery, and Clear Methods Example (VBScript) 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 ExecuteCommand and PrintOutput procedures are required for this procedure to run. Use the following example in an Active Server Page (ASP). To view this fully functional example, you must either have the data source AdvWorks.mdb (installed with the SDK samples) located at C:\Program Files\Microsoft Platform SDK\Samples\DataAccess\Rds\RDSTest\advworks.mdb or edit the path in the example code to reflect the actual location of this file. This is a Microsoft Access database file. Use **Find** to locate the file Adovbs.inc and place it in the directory you plan to use. Cut and paste the following code into Notepad or another text editor, and save it as **ExecuteVBS.asp**. You can view the result in any client browser. ``` <%@ Language=VBScript %> <% ' use this meta tag instead of ADOVBS.inc%>
| Company Name | Contact Name | City |
|---|---|---|
| <%= rsCustomers("CompanyName")%> | <%= rsCustomers("ContactName") %> | <%= rsCustomers("City")%> |
| Product Name | Unit Price |
|---|---|
| <%= rsProducts("ProductName")%> | <%= rsProducts("UnitPrice")%> | <% rsProducts.MoveNext Loop ' clean up If rsCustomers.State = adStateOpen then rsCustomers.Close End If If rsProducts.State = adStateOpen then rsProducts.Close End If If Cnxn.State = adStateOpen then Cnxn.Close End If Set Cmd = Nothing Set rsCustomers = Nothing Set rsProducts = Nothing Set Cnxn = Nothing %>