Data Access  «Prev 

Accessing data with Design Time Controls

  1. Make sure the VirtualBookShelf project is open in PHP. Start by clicking Project on the menu bar.
  2. To add a new page, select "Add Item."
  3. The Add Item dialog is displayed. We want to add an ASP page, so select ASP Page.
  4. The page should have a meaningful name. Enter customers.asp as the name of the page into the Name field. Then click Open.
  5. 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.
  6. 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.
  7. Select Properties from the menu.
  8. 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.
  9. Now select CustTable in the Source of data Object name box.
  10. These are all the properties that need to be set. Click the close button.
  11. 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.
  12. 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.
  13. Select Properties from the menu.
  14. 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.
  15. Select the CustRecords recordset in the Recordset box.
  16. 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.
  17. Select CustNo.
  18. Now the customer number field is bound to the Textbox control named CustID. Click OK to finish up.
  19. 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.
  20. 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.
  21. Select “View in Browser” from the menu.
  22. 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.