When we're querying a database, we will usually need to press a submit button on a form to pass data to another ASP page, which would generate the query, and return the results. In some situations, this page refresh is just plain annoying and takes too long to complete. In this article, Phanix will describe another way to query a database using a combination of web technologies.
Grabbing Data On The Fly - Using frames to solve the refresh problem (Page 3 of 6 )
Suppose that we manage an online bookstore, and that we use a web page to add new books to the database. While we are keying in the details of a new book, suppose we aren’t sure of the author. We could create a form that would allow us to enter part of the authors name and then select the author from a list of possible authors who match our criteria. The form might look like this:
Suppose the drop down component of “Author” is named “AuthorID”. This example will work with the sample SQL database, pubs. Our author database holds the values of author ID (au_id), author name (au_lname), etc. We want to display author name in the drop down component, and author ID as the value of each item in the drop down component. We can enter a keyword in the text field of “Query”, then click the “Query” button. After clicking, the keyword will be sent to a hidden frame (frame size is zero) named “ProcessFrame”. An ASP script will execute a LIKE SQL query on the authors’ table of the pubs database in the “ProcessFrame” and return the result to the source frame (named “MainFrame”). Lastly, the “Author” drop down component will be filled with the results of the query. The flow of operation looks like this: