Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 8

Adding Connection and Command Objects With the Data Environment Designer in VB6

You can add Connection and Command objects to a Data Environment Designer. You can then manipulate these objects from VB's Visual Design Environment, or in VB code.

STEP BY STEP
8.2 Adding Connection and Command Objects

  1. Make sure that your VB project contains a Data Environment Designer, as discussed in the preceding section.

  2. Right-click on the Data Environment Designer's surface, and choose Add Connection, as shown in Figure 8.3.

    Adding a Connection object to a Data Environment Designer.
    FIGURE 8.3. Adding a Connection object to a Data Environment Designer.

  3. Right-click on the Connection object, and then choose Properties from the drop-down menu.

  4. On the Provider tab (see Figure 8.4), choose an OLE DB Data Provider. (Some choices are Microsoft Jet 3.51 OLE DB (for MS Access databases), Microsoft OLE DB Provider for ODBC Drivers, or Microsoft OLE DB Provider for SQL Server.)

    Choosing the provider for a Connection object in the Data Environment Designer.
    FIGURE 8.4 Choosing the provider for a Connection object in the Data Environment Designer.

  5. On the Connection tab (see Figure 8.5), set up the specific data connection with the following steps. (Note that the contents of the tab will differ depending on the type of data provider selected on the Connection tab.)

  6. Set up the source of the data, whose nature will vary depending on the type of connection. For a Jet data source (Microsoft Access), you will specify the MDB file's name and path. For an ODBC data source, you can specify a data source name (based on an existing DSN) or a connection string that creates a new DSN.

    Setting up connection information for a Connection object in the Data Environment Designer.
    FIGURE 8.5 Setting up connection information for a Connection object in the Data Environment Designer.

  7. Fill in logon information about the username and password.

  8. Click OK to accept the ODBC Data Source options you have built.

After you have data connections established, you can add Command objects to the data connections.

STEP BY STEP
8.3 Adding Command Objects to the Data Connections

  1. Right-click a Connection object and choose Add Command from the drop-down menu, as in Figure 8.6.

    Adding a Command object to a connection in the Data Environment Designer
    FIGURE 8.6 Adding a Command object to a connection in the Data Environment Designer

  2. On the General tab, give a name to the new Command object, as in Figure 8.7.

    Setting general information about a Command object in the Data Environment Designer.
    FIGURE 8.7 Setting general information about a Command object in the Data Environment Designer.

  3. Change the connection information if you want to, or leave it the same to accept the default Connection information from the Connection object.

  4. Choose the Source of Data Database Object = Table, Stored Procedure, View, or Synonym) (see Figure 8.8).

    Setting information about the data source for a Command object in a Data Environment Designer.
    FIGURE 8.8. Setting information about the data source for a Command object in a Data Environment Designer.

  5. On the Advanced tab (Figure 8.9), you can set cursor type, cursor location, locking strategy, and cache size. See later sections in this chapter on each of these subjects.

    Advanced settings for a Command object in a Data Environment Designer.
    FIGURE 8.9. Advanced settings for a Command object in a Data Environment Designer.

  6. Rename the object if you want.

  7. Click OK. Your Command object is finished.

NOTE - Cursor Options on the Advanced Tab: You can fine tune the Recordset's behavior by setting the CursorLocation, CursorType, and Locktype properties with the correspondingly labeled fields on the Advanced tab. These properties and their meaning are discussed at length in the next chapter.

See Also

 


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved