The current process flow is directly between the ASP page and the database.
A DLL will act as an intermediary- the ASP page will talk to the DLL, which will talk to the database. Picture it like this:
[][]
ASP <---> DLL <---> Database
[
][
]
The arrows indicate communication links.
You will need to pass the information from your ASP page to the DLL. The DLL will query the database, then return the results to the ASP page.
The goal is to get the DLL to do as much work as possible in order to speed up processing of the page. Recall that ASP code is interpreted- it is compiled and executed one line at a time every time the page is requested. A DLL is pre-compiled.
The DLL will contain public functions. Recall that, in Visual Basic, a function is a section of code that returns a value. The public functions may or may not take arguments, depending on what work needs to be done. Recall that an argument, or parameter, is information passed into the function that acts as a local variable. I will first discuss a simple process for handling arguments, then I will discuss returning the data to the ASP page. Finally, I will discuss how it applies to each of our ASP pages.
We can divide functions into three categories, based on how many arguments they take: zero, one, or many. The first two require no special handling, they are handled just the same as any other function. However, a form may contain dozens of fields. To pass every field value as an individual argument to a function would get complicated. The line of code would be very long and difficult to read. A simpler way of handling multiple arguments is to convert them into an array, then pass the array as one argument to the DLL function.
To keep our ASP running quickly and smoothly, we want to avoid creating a lot of objects. This includes RecordSets. You should NOT be creating recordsets in ASP! Instead, the DLL will return the data as an array.
A breakdown of our pages, and related functions, would be:
[
]
[]
[]View List[ | ]
[]
Since we want all records, we don't need to pass an argument to the function. The function will return an array containing all data for all records.
[ | ]
[
]
[]
[]View Detail[ | ]
[]
Since we want just one specific record, we need to pass the UniqueID of the record we want to the function. Then function will return an array containing all the data for the one record.
[ | ]
[
]
[]
[]Edit Detail[ | ]
[]
Since we want just one specific record, we need to pass the UniqueID of the record we want to the function. Then function wull return an object containing all the data for the one record.
[ | ]
[
]
[]
[]Update Detail[ | ]
[]
This page will do one of three things:
[]
[- ]Add a new record[
]
[- ]Update an existing record[
]
[- ]Delete an existing record[
]
[ ]
For cases 1 and 2, we need to pass all the field values from the form. So, this will be converted to an array and passed to the function as one argument. The function will return a number for records affected.
For case 3, we are deleting a specific record, so we will pass the UniqueID of the record to the function. The function will return a number for records affected.
[ | ]
[
]
[
]
I will explain all of this in more detail, and provide an examples, in the next lectures. For now, it is important to be able to understand the process flow.