The information in this article applies to:
- Microsoft Visual InterDev, version 1.0
SUMMARY
Microsoft Visual Interdev provides a DataForm Wizard that will generate
Active Server Pages that can be used to access a database back-end. These
forms provide filtering capability. When these filters are used to filter
large recordsets, performance may suffer. An alternative approach is to
requery the server for a new recordset each time you apply a filter. This
article describes how to change a data form to use this approach.
MORE INFORMATION
To begin, you will need some DataForm Wizard-generated files on which to
work. Use the following steps to create these files based on the Adventure
Works database file that is installed with Active Server Pages:
- Create a new web project using the Web Project Wizard.
- After the web project is created, use the mouse to right-click on the
GLOBAL.ASA file.
- Choose "Add Data Connection."
- Choose "AdvWorks" under the "Machine Data Source" tab.
- Change the name of the data connection from "DataConn" to "AdvWorks,"
and then close the "Data Connection Properties" window.
- Open the "File" menu.
- Choose "New."
- Choose the Second tab, "File Wizards."
- Highlight "Data Form Wizard."
- Type in "Requery" in the File Name text box.
- In the list box, "What database connection do you want to use?"
select "AdvWorks."
- Press the Next button twice to move to "Step 3 of 7" in the
DataForm Wizard.
- Add all fields from the "Customer" table by clicking on the
">>" button.
- Click the Next button four more times, accepting the defaults of all
the remaining wizard steps.
- Click the finish button.
You will now have the files:
RequeryForm.asp
RequeryList.asp
RequeryAction.asp
Make the changes outlined below to the RequeryForm.asp file and the
RequeryAction.asp file to change from a filtering model to a requery model.
RequeryForm.asp
Change the RequeryForm.asp file to store the Query in a session variable so
that you can alter it later. Store the cmdTemp object in a session object
so you can modify its CommandText property before requerying. To do all
this, follow these steps:
- Open RequeryForm.asp.
- Press CTRL+F to open the search dialog.
- Type "Set cmdTemp" in the "Find What" text box.
- Press the "Find Next" pushbutton.
- Press the F3 key to find the second occurrence of this string. The
string should read "Set cmdTemp.ActiveConnection = AdvWorks."
- Insert a new line on the line following the line that is now
highlighted.
- Place the following lines of code on the newly inserted line:
'**************
Set Session("cmdTemp") = cmdTemp
Session("CommandText") = cmdTemp.CommandText
'**************
- Save this file and close it.
RequeryAction.asp
You now need to change the RequeryAction.asp so that a WHERE clause is
added to the SQL statement that provides your records. Follow these steps:
- Open the RequeryAction.asp page.
- Press CTRL+F to open the search dialog.
- Type "All Records."
- Press the "Find Next" button.
- Six lines down you will see the line:
Session("rsRequeryCustomers_AbsolutePage") = 1
- Insert a new line after this line.
- Place the following lines of code here:
'**************
Session("cmdTemp").CommandText = Session("CommandText")
Session("rsRequeryCustomers_Recordset").Requery
'**************
- Press CTRL+F to open the search dialog again.
- Type in "Filter the recordset," and press the "Find Next" button.
- Four lines down you will see the line:
Session("rsRequeryCustomers_AbsolutePage") = 1
- Insert a new line after this line.
- Place the following lines of code here.
'**************
Session("cmdTemp").CommandText = Session("CommandText") & " WHERE " _
& strWhere
Session("rsRequeryCustomers_Recordset").Requery
'**************
- Save this file and close it.
You can now browse RequeryForm.asp in your browser. When you press the
Filter button, the query will be set to its original state and a requery
will be performed. After you enter filter criteria, they will be appended
to the SQL query and another query will be performed.
REFERENCES
For the latest Knowledge Base articles and other support information on
Visual InterDev and Active Server Pages, see the following page on the
Microsoft Technical Support site:
http://support.microsoft.com/support/vinterdev/
Keywords : VIWizards kbtool kbhowto
Technology : kbInetDev
Version : 1.0
Platform : WINDOWS
Issue type : kbhowto