Visual InterDev

Getting Records

See Also

Getting and displaying records from a database is one of the key features of Microsoft® Visual InterDev™. You manipulate data using data-bound design-time controls, primarily the Recordset control.

A Recordset control is bound to a particular database using a database connection, and specifies a particular set of records from that database. For more information on the control and its properties, see Recordset Design-Time Control.

Visual InterDev makes it easy to create Recordset controls by using the data environment. You can also create Recordset controls by using the Toolbox, and then associate these controls with the data environment. For information on how the data environment is related to controls and other database features of Visual InterDev, see Data Access Architecture.

To create a Recordset control using the data environment

  1. In your Visual InterDev project, add a data connection to the database whose records you want to display. For details, see Connecting to a Database.

    The data connection is displayed in Project Explorer in the DataEnvironment folder, underneath the Global.asa file.

    Tip   You can also right-click the DataEnvironment folder and then click Add Data Connection to create a data connection. The same set of dialog boxes is displayed that appears when you use the Add Data Connection command on the Project menu.

  2. Right-click the DataEnvironment folder and select Add Data Command.

    The Command Properties page is displayed.

  3. Enter a name for this Command object in the Command Name box, such as CustomersTableRecords.

  4. Select the data connection in the Connection box. If you selected a data connection in the DataEnvironment folder before you clicked Add Data Command, this data connection will already be in the Connection box.

  5. If you want the Command object to contain the set of records in a table, query, view, stored procedure, or other type of database object, select the button next to the Database Object box.

    Then select this type of database object in the Database Object box and the name of an object of this type in the database in the Object Name box.

  6. If you want to use an explicit SQL statement to select the recordset you want, select the button next to the SQL Statement box. Then enter the SQL statement in the SQL Statement box.

    To construct this SQL statement, you can press the SQL Builder button, and use the SQL Builder.

    At any time, you can drag the Command object onto an ASP or HTML page. This creates a Recordset object, which is bound to the specified set of records in the database.

Using the data environment is the preferred method to create Recordset controls. Once the Command object is created using the data environment, modifying the Command object is simple. You only need to update the object once in the data environment. You don't have to continually recreate a Recordset control on different ASP or HTML pages for the same set of records.

You can, however, insert a Recordset control onto an ASP or HTML page from the Toolbox, and then associate this Recordset control with an existing Command object in the data environment.

To associate a Recordset control with a Command object

  1. Open an ASP or HTML page in the editor.

  2. Drag the Recordset control from the Toolbox onto the page.

    Tip   If the Recordset control is not shown in the Toolbox, right-click on the Toolbox, choose Customize Toolbox, and add the Recordset control.

    The Recordset control displays the Connection, Database Object, and Object Name fields. These are properties of the Recordset object.

  3. In the Recordset control on the ASP or HTML page, set the Connection property to the name of the data connection for the database whose records you want to see. This is the database that the Command object is connected to.

  4. Set the Database Object property to DE Commands.

  5. Set the Object Name property to the name of the Command object in the data environment.

For more information about setting the properties for the Recordset control, see Recordset Properties Dialog Box.

Now that you've created a recordset and specified its records, you can display data from this recordset on a Web page. For more information, see Displaying Data on Your Web Page.