Accessing data with Design Time Controls
- Make sure the VirtualBookShelf project is open in PHP. Start by clicking Project on the menu bar.
- To add a new page, select "Add Item."
- The Add Item dialog is displayed. We want to add an ASP page, so select ASP Page.
The page should have a meaningful name. Enter customers.asp as the name of the page into the Name field. Then click Open.
The page is now added to the project. The next step is to add a Recordset DTC. You add a Recordset DTC by dragging it from the toolbox and dropping on the page,
just before the </HEAD> tag. For the purpose of this simulation, just click the Recordset DTC and we will drag it for you.
Now a Recordset DTC is embedded in the page. The gray box labeled Recordset1 in the upper left corner represents the control. Next, the
control's properties must be set to reference the customer table. Place the cursor over the control in the source code editor and right-click.
Select Properties from the menu.
It's a good idea to assign a meaningful name to the control. This way, it is easy to determine what the control is used for. In the
Recordset Properties dialog, enter CustRecords in the Name box. Then you need to associate the control to a table in the database. Click
the down arrow to the right of BookTable in the Object Name box.
- Now select CustTable in the Source of data Object name box.
- These are all the properties that need to be set. Click the close button.
Now that the properties are set, HTML DTCs can be bound to the recordset DTC. In this example, the CustomerID, LName, and FName fields of
the CustTable will be bound to Textbox controls, which will display their values on the Web page. To add these controls, normally you would
click and drag a Textbox control to the page and drop it just above the </BODY> tag. However, for the purpose of this simulation,
just click the Textbox control and we will drag it for you.
- Just like the Recordset DTC, the Textbox control's properties are set to reference a data field, such as CustNo or LName, in the table. Right-click the Textbox control.
- Select Properties from the menu.
- This control will display the customer number, so name it CustID to clearly indicate its use. Next, you need to associate this control to the CustRecords Recordset DTC. Click the down arrow located on the right side of the Recordset field.
- Select the CustRecords recordset in the Recordset box.
- Now you need to specify which field should be displayed. Click the arrow to the right of the Field box to pull down a list of fields.
- Select CustNo.
- Now the customer number field is bound to the Textbox control named CustID. Click OK to finish up.
That takes care of the customer number. You can see that the Textbox DTC, which you named CustID, has been placed just below </Head>.
There are two more Textbox DTCs that need to be added -- last name (LName) and first name (FName). These are added by following the steps
that you just completed for adding the customer number Textbox DTC. The only difference would be how you set Textbox properties by
assigning the names and selecting the fields of LName or FName. Click Next and we will show you what it looks like when all the Textbox DTCs
are in place.
Whew! That was a bit of work! Now there are three Textbox controls to display the customer number (CustID), last name (LName), and first
name (FName). Now it's time to see the results by viewing it in the browser. Right-click the source editor.
Select View in Browser from the menu.
The first customer record is displayed. Only one record is displayed now. As records are added, you will want to add a RecordsetNavBar
control, which lets you navigate forward and backward in the recordset. This will be covered in the lesson "Displaying Data on the Web".
This is the end of the simulation.