--- title: "Find Method 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: - "Find method [ADO], JScript example" ms.assetid: adb5c37e-7874-41db-b4ee-572c1323deff author: MightyPen ms.author: genemi --- # Find Method Example (JScript) This example uses the [Recordset](../../../ado/reference/ado-api/recordset-object-ado.md) object's [Find](../../../ado/reference/ado-api/find-method-ado.md) method to locate and display the companies in the ***Northwind*** database whose name begins with the letter G. Cut and paste the following code to Notepad or another text editor, and save it as **FindJS.asp**. ``` <%@ Language=JavaScript %> <%// use this meta tag instead of adojavas.inc%> ADO Recordset.Find Example

ADO Recordset.Find Example

<% // connection and recordset variables var Cnxn = Server.CreateObject("ADODB.Connection"); var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" + "Initial Catalog='Northwind';Integrated Security='SSPI';"; var rsCustomers = Server.CreateObject("ADODB.Recordset"); // display string var strMessage; var strFind; try { // open connection Cnxn.Open(strCnxn); //create recordset using object refs SQLCustomers = "select * from Customers;"; rsCustomers.ActiveConnection = Cnxn; rsCustomers.CursorLocation = adUseClient; rsCustomers.CursorType = adOpenKeyset; rsCustomers.LockType = adLockOptimistic; rsCustomers.Source = SQLCustomers; rsCustomers.Open(); rsCustomers.MoveFirst(); //find criteria strFind = "CompanyName like 'g%'" rsCustomers.Find(strFind); if (rsCustomers.EOF) { Response.Write("No records matched "); Response.Write(SQLCustomers & "So cannot make table..."); Cnxn.Close(); Response.End(); } else { Response.Write(''); Response.Write(''); // Put Headings On The Table for each Field Name for (thisField = 0; thisField < rsCustomers.Fields.Count; thisField++) { fieldObject = rsCustomers.Fields(thisField); Response.Write('"); } Response.Write(""); while (!rsCustomers.EOF) { Response.Write(''); for(thisField=0; thisField" + strField + ""); } rsCustomers.Find(strFind, 1, adSearchForward) Response.Write(""); } Response.Write("
' + fieldObject.Name + "
"); } } catch (e) { Response.Write(e.message); } finally { // clean up if (rsCustomers.State == adStateOpen) rsCustomers.Close; if (Cnxn.State == adStateOpen) Cnxn.Close; rsCustomers = null; Cnxn = null; } %> ``` ## See Also [Find Method (ADO)](../../../ado/reference/ado-api/find-method-ado.md) [Recordset Object (ADO)](../../../ado/reference/ado-api/recordset-object-ado.md)