Database Access Controls VB6

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search

Visual Basic 6 supports ActiveX Data Objects. You can use ADO to connect to a database on a local desktop or to a remote database server. Also, ADO allows you to access more types of data--e-mail, for example. The ADO data control allows you to connect to a desktop database file or an ODBC server on a network, or you can create a new connection to another database. The ADO data control combines the functionality of DAO and RDO, as well as allows you to access non-traditional data types such as e-mail or files within the file system.

There is a set of tools and technologies that make data access easier. The Data Environment Designer allows you to view and manipulate data in various databases. Because data environments are objects in their own right, you can use them as you would a Data control. You can even bind other controls, such as a TextBox or Label, to a Data control.

  • The DataGrid allows you to view your data in a row and column format.
  • The DataList and DataCombo are used to get a pick list of data from an ADO control in a ListBox or ComboBox configuration.
  • The FlexGrid and hierarchical FlexGrid controls get a clear, visual view of complex data.

The Data Report Designer lets you create, preview, and print reports in Visual Basic. You set report controls from the Data Reports Toolbox onto the Data Report form. Then you invoke the Data Report's PrintReport() method.

Grid Types

  • DBGrid, DataGrid, MSFlexGrid, MSHFlexGrid, and Sheridan Grids (SSDBGrid, etc.).

Common grids:

  • MSFlexGrid
  • DataGrid

Background:

  • The DataGrid control replaces the old DBGrid control from previous versions of Visual BASIC
  • Don't confuse the FlexGrid control with the DataGrid control—both controls use the same icon but behave differently.
  • The difference between the flex grid controls and the DataGrid control is that both versions of the flex grid control only allow you to look into the database, a snapshot and not a dynaset. With the DataGrid control you can look into the data as well as build up the grid and edit the data.

Editing Data

You can use a DataGrid which does support Add, Update, and Delete data. The DataGrid control allows you to update the database. The MSFledGrid control does not.

You cannot edit data in an MSFlexGrid without doing some trickery: One trick is to use a hidden text box control with a Grid.OCX (VB4) or a MSFlexGrid.OCX (VB5/6) control to make an editable grid control. It would work by having a hidden textbox on the same form as the Grid Control and positioning it over the relevant cell when editing is to occur. Reference: