Chapter 5 -- Introduction to the Data Environment

Chapter 5

The Data Environment (DE) in Microsoft Visual InterDev 6.0 collects your data connection and data manipulation code in one place. The Data Environment provides a standard interface for creating data-related objects and for placing them on Web pages. It also provides a layer of abstraction, allowing you to create and modify objects that represent your data independently of the database.

The Data Environment is a new object-based wrapper around ActiveX Data Objects (ADO) and is used in both Visual InterDev 6.0 and Microsoft Visual Basic 6.0. The consistency of using the Data Environment in both Visual InterDev and Visual Basic makes developing applications in either environment easy. Moving from Visual InterDev to Visual Basic, and vice versa, also becomes easier. This integration is likely to increase as we see new versions of Microsoft development tools in Visual Studio.

The Visual InterDev 6.0 Data Environment is created automatically when a data connection is added to a project. The DataEnvironment folder is displayed beneath the global.asa file in Project Explorer. Any data connections you add are displayed in the DataEnvironment folder.

Using the Data Environment is the easiest way to create data-driven web pages. You can create data command objects that live at the DE level in your project and can be used by any ASP file in the project. You don't have to continually re-create a Recordset control on different ASP Web pages for the same set of records as we did in Visual InterDev 1.0. Now you can create a data command object once and use it to quickly create Recordset controls by dropping them into an ASP file in the editor.

Data-bound design-time controls (DTCs) are the basic building blocks for connecting to databases and displaying data on your Web pages. The Data Environment allows you to create and manage all your DTCs in one location. You don't need to create new controls for each Web page, and you need to create controls for the same set of records only once. Because your database code can be used repeatedly, building, debugging, and maintaining applications is much easier.

A useful feature of the DE is the variety of drag-and-drop options. You can:

  • Drag objects from the Data Environment and drop them into an ASP file to automatically create data-bound DTCs
  • Drag the fields from a data command object's recordset and drop them onto an ASP Web page to automatically create data-bound DTCs
  • Drag a table from Data View and drop it into an ASP file under a Recordset DTC created from dragging and dropping a data command object onto the page

Figure 5-1 shows the Data Environment as it looks in Project Explorer with one data connection and one data command. You can see how the DE is attached to global.asa.

Figure 5-1. The Data Environment as displayed in Project Explorer under global.asa.

Figure 5-1 shows the Northwind data connection and the GetCustomers data command. You can also see the fields in the GetCustomers recordset displayed beneath it. Each of these fields has a default data-bound DTC. The default is based upon the field's data type. You can right-click a field and assign it a specific DTC. That DTC will be used every time you drag the field from the recordset and drop it onto a page. We will discuss DTCs in more detail in Chapter 6 and throughout the remainder of the book.



Programming Microsoft Visual InterDev 6. 0
Programming Microsoft Visual InterDev 6.0
ISBN: 1572318147
EAN: 2147483647
Year: 2005
Pages: 143

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net