Accessing Data Using Visual Basic
The document is archived and information here might be outdated

Visual Basic Concepts

Visual Studio 6.0
https://msdn.microsoft.com/en-us/library/aa244199(v=vs.60).aspx

Accessing Data Using Visual Basic

The figure below is a roadmap of data access technologies found in Visual Basic. The figure features "hot" zones, which you can click to find out more information about any particular set of data, access tools or technologies.

vbconDataAwareControls.htm vbconDHTMLVisualBasicDataAccess.htm vbconUsingMicrosoftDataReportDesigner.htm vbconDataBindingInVisualBasic.htm vbconDataBindingInVisualBasic.htm vbconVisualBasicDataSources.htm vbconVisualBasicDataSources.htm vbconRemotingFeaturesOfVisualBasic.htm vbconRemotingFeaturesOfVisualBasic.htm vbconUsingADODAORDOInVisualBasic.htm vbconMiddleTierComponents.htm vbconCreatingOLEComponents.htm vbconTheDataViewWindow.htm

Microsoft Visual Data Tools

Using Visual Basic 6.0 you can create components that encapsulate every step in a data access system. Beginning with the data source, Microsoft Visual Data Tools (accessible through the Data View window) give you the ability to view and manipulate tables, views, stored procedures, and database schemas on SQL Server and Oracle systems.

Middle Tier Components and Microsoft Transaction Server

The power of Visual Basic is also leveraged to create the middle tier components in your application, as you make your own ActiveX DLLs and EXEs. Visual Basic now includes enhancements that tailor applications to work with Microsoft Transaction Server.

ActiveX Data Objects (ADO)

The bridge between the data providers and data consumers is through data sources created using Microsoft ActiveX Data Objects (ADO), which is the primary method in Visual Basic to access data in any data source, both relational and non-relational. For backward compatibility and project maintenance, Remote Data Objects (RDO) and Data Access Objects (DAO) are still supported.

Data Sources and Data Controls

On the client side, several new data sources are available, including the Data Environment, a graphical designer that allows you to quickly create ADO Connections and Commands to access your data. The Data Environment designer provides a dynamic programmatic interface to the data access objects in your project. In addition, the Data Environment provides advanced data shaping services — the ability to create hierarchies of related data, aggregates, and automatic groupings, all without code.

The new ADO Data control is similar to the intrinsic data control and Remote Data control, except that it uses ADO to access data. You can now use an ADO Recordset as a data source for your controls and objects in Visual Basic.

In Visual Basic you can now create your own data sources either as user controls or classes, to encapsulate business rules or proprietary data structures. The class module now features the DataSourceBehavior property and the GetDataMember event, which allow you to configure a class as a data source.

Dynamic Data Binding

The ability to dynamically bind a data source to a data consumer is now possible in Visual Basic. At run time, you can now set the DataSource property of a data consumer (such as the DataGrid control) to a data source (such as the ADO Data control). This capability, unavailable in previous versions of Visual Basic, allows you to create applications, which can access a multitude of data sources.

Presenting Data to the End User

Visual Basic offers a variety of rich ways to present data to your end users. ADO/OLE DB-based versions of all the data bound controls are included in Visual Basic:

  • The DataList and DataCombo controls are the ADO/OLE DB equivalents of DBList and DBCombo controls.

  • The DataGrid is the successor to DBGrid.

  • The Chart control is now data bound.

  • A new version of the FlexGrid control, called the Hierarchical FlexGrid, supports the hierarchical abilities of the Data Environment.

  • The new DataRepeater control functions as a scrolling container of data bound user controls where each control views a single record.

The Data Report is a new ActiveX designer that creates reports from any data source, including the Data Environment. With the Data Report designer, formatted reports can be viewed online, printed, or exported to text or HTML pages.

Data Formatting and Data Validation

The new DataFormat object allows you to display data with custom formatting, but write it back to the database in the native format. For example, you can now display dates in the format appropriate to a country, while the actual data is stored in a date format. Data is formatted coming out of the source, and unformatted going back in. You can also do custom formatting and perform additional checks using the Format and Unformat events.

Data validation is also enhanced using the CausesValidation property with the Validate event. By setting the CausesValidation property to True, the Validate event for the previous control in the tab order will occur. Thus, by programming the Validate event, you can prevent a control from losing focus until the information it contains has been validated.

Language Features

New data-related enhancements to the Visual Basic language include the ability to pass User-defined Types (UDTs) and arrays across processes. You can now define a UDT and pass it as a parameter to another process, such as an ActiveX EXE or DLL.

DHTML and Data Access

Using Visual Basic, you can create complete web applications for data access. All of the data tools and technologies can also be used in DHTML pages, and on web server (IIS) applications.

Other Enterprise features

For information on data access programming in the enterprise, see in Developing for the Enterprise.

Show:
© 2016 Microsoft