Content Supported by Sourcelens Consulting
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY bgColor=#ffffff leftMargin=40 link=#500000 vLink=#505050>
<FONT FACE="Verdana, Arial, Helvetica" SIZE=2>
<FONT SIZE=4 COLOR=#500000>Behind the Scenes</FONT>
<BR><BR>
<P>This sample uses one file: Query.asp. After the user
enters the search criteria the results are displayed using a data-bound grid.
</P>
<P>To create the dynamic query a function must be called to
set the SQL statement for the recordset. The function first determines if the
user selected CONTAINS or BEGINS WITH from the first drop-down and then builds
the SQL statement. </P>
<P>The new SQL statement is sent to the recordset and the
new recordset is opened. The function below shows the code that is executed once
the Search button is clicked: </P>
<FONT FACE="Courier">
<P>function Button1_onclick() { <BR> if (Listbox2.getValue(Listbox2.selectedIndex) ==
"Contains") { <BR>
newSQL = "Select * FROM Customers WHERE (" +
Listbox1.getValue(Listbox1.selectedIndex) + " LIKE '%" +
Textbox1.value + "%')"; } else { newSQL = "Select * FROM
Customers WHERE (" + Listbox1.getValue(Listbox1.selectedIndex) + "
LIKE '" + Textbox1.value + "%')"; } <BR> DTCRecordset1.setSQL(newSQL); <BR> DTCRecordset1.open(); <BR>
} </P>
</FONT>
<P>After the new recordset is opened the results are
displayed using a data-bound grid. The grid displays the data in pages of ten
records each.</P></FONT>
</BODY>
</HTML>