A Parameterized SQL Query is used to do a few things.
- Retrieve data from a database to present on the webpage.
- Help protect your database from [SQL Injections].
Below, I am going to list the different methods I use for performing these very powerful actions to get the information from [
SQL Server] to our [
Classic ASP] / [
VBScript] coded page.
To return a single record based on a [
QueryString] value.
[
Example 1]
To return a multile records based on a [
QueryString] value.
[
Example 2]
Next is one that I've used in the past for a large [
SQL Statement], but stopped using it due to a lack of knowledge of its use.
However, I just began the new redesign of our Radio site, and am going to implement this for all complex loop [
Queries].
[
Example 3]
OK, let's look at the code above and how it works.
In [ASP Classic], [GetRows] and [MoveNext] are methods for processing database recordsets with different performance profiles. [GetRows] dumps the entire recordset into a 2D array in memory, allowing for fast, disconnected processing. [MoveNext] iterates through the recordset row-by-row, keeping a live connection, which is memory-efficient but slower.
The array is presented by items from the Select statement.
I run a SQL Script that gives me a list, in order, of all the columns.
I then present them like this.
The bottom code will throw out the data to your page a lot faster than the one in Example 2