Материал: Крючков Фундаменталс оф Нуцлеар Материалс Пхысицал Протецтион 2011

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

allow one both to handle database data directly and get SQL queries running. These object collections are continuously updated with new ones coming out. One of the earliest collections of the kind was DAO (Data Access Objects) [17]. This gave applications the capability to manipulate data which could be communicated with via the SQL query language. Fig. 7.6 presents a DAO-realized object hierarchy.

This collection can be engaged by an application created with the employment of Microsoft Visual Studio for communication with data in formats of popular DBMSs and spreadsheets, e.g. Access or Excel. This also permits the user to get connected to the database with the connection kept by the application that remains open throughout the session. Data from tables or with the aid of SQL queries are copied into datasets (Recordset object). Recordset objects include the sufficient number of methods to allow navigating the dataset and carrying out search functions, that is, doing everything needed to operate data.

DBEngine

Workspace

Database

 

 

 

 

TableDef

 

 

 

QueryDef

 

 

 

Recordset

 

 

Container

 

 

 

Relation

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Field

 

 

 

 

 

Field

 

 

 

 

Field

 

 

 

 

Document

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Field

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Parameter

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Index

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Error

 

 

 

 

Field

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Fig. 7.6. Hierarchy of objects in the DAO collection of data access object classes

A great deal of data sources, say, those certified for use in MS SQL Server and Oracle NM A&C systems, cannot be however operated directly from DAO. Data in these formats are accessible via a more universal data access technique. ODBC (Open Database Connectivity) is utilized by Microsoft to handle data in various formats.

331

ODBC is a set of drivers and interfaces enabling connectivity to various platforms and use of a standard query language for different data management types. To implement access to data storable in different formats, the required drivers are installed into the operating system and a particular database in the format selected is given the logical name of the ODBC set. Thereafter, the application program developer can afford not to think about a particular data presentation because it is enough for him just to employ standard SQL queries to create DAO Recordsets from the databases of any formats. The application can subsequently handle data with the aid of a high-level language and, as required, update data in the database or add new data thereto using standard SQL queries.

DAO was used to create a great deal of database applications. Thus, in particular, it is used for handling data in the LANL-developed computerized NM A&C system (LANMAS) and in COREMAS, its localized version for applications in Russia and other CIS membercountries.

There is another collection of classes to mention in the context of database access objects. This is RDO (Remote Database Objects), which has been optimized to operate in client-server applications. Similarly to DAO, RDO uses ODBC for connections to remote data sources. This collection of object classes was employed by the Kurchatov’s developers to build КИМАКС, a computer-based NM A&C system.

The evolution in ITs has brought about changes to information systems. To begin with, Web-accessible program applications appeared. This required new objects of access to data to be used for Web-applications. Further on, the development of business support electronics brought to life the demand for access to such nonrelational data as electronic documents and letters and others. For support of these capabilities, OLE DB (Object Linking and Embedding), a new technology for accessing all kinds of data, and ADO (ActiveX Data Objects), a new collection of object classes [17], were developed. Unlike ODBC, OLE DB can connect applications to data in any formats. In particular, it can also use ODBC drivers for connections to relational databases. To make use of OLE DB, one needs the services of an OLE DB provider which is to be installed for each type of data sources. OLE DB providers are supplied in the operating system and DBMS delivery packages. Therefore, using ADO with an OLE DB provider for ODBC, one can get the same functionality as with DAO and RDO. Along with this, ADO objects do not form such a stiff hierarchical structure as DAO and will offer more flexibility in handling data in different formats. Fig. 7.7 presents a schematic of the ADO collection of classes.

332

 

 

 

 

Collection

 

 

 

 

 

 

Command

 

Parameter

 

 

 

 

 

 

 

 

(Optional)

 

 

(Optional)

 

 

 

 

 

 

 

 

 

Execute

 

 

 

 

 

 

Execute

Source

 

 

 

 

 

Collection

 

 

 

 

 

 

 

 

 

 

Connection

 

 

Recordset

 

 

Field

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Connection

Error (Optional)

Fig. 7.7. ADO collection of data access object classes

Until recently, ADO was the central component of access to data in Windows-based applications. These components were supported by a number of software products from outside developers, e.g. Borland Delphi. They have an important role in creation of database applications, so we shall discuss them in more detail.

All ADO objects, excluding Error and Field, can be opened independently. The Command, Error and Parameter objects are not mandatory. Connection is the object that encapsulates communication with the data source within. It possesses the Execute method which returns, as the result of the query accomplished, the Recordset object containing a data sample. The Recordset object is the core of ADO. It can be also created independently of other objects and enables navigation through record sets, addition, deletion and editing of records, as well as retrieval and filtration of information. A number of examples follow to illustrate the principal object methods.

Let there be an ODBC-configured data source the name whereof is stored in the string variable myDSN. Then the following sequence of commands on VB will establish connection with the said data set. Further, the SQL query creates the Recordset object that contains Titles table data:

Dim myADOConnection As New ADODB.Connection Dim myRecordset As ADODB.Recordset MyADOConnection.Open myDSN

Set myRecordset = MyADOConnection.Execute(«Select * from titles»)

333

Further on, one can operate the data selected using Recordset’s methods and properties. Table 7.1 presents Recordset methods and Table 7.2 presents Recordset basic properties.

Table 7.1

 

 

Recordset methods

 

 

 

 

 

Method

Description

AddNew

Creates a new record for the Recordset

Close

Closes the open Recordset

Delete

Deletes the current record

GetRows

Returns the number of rows

Move

Moves the position of the current record

MoveFirst

Moves to the first record

MoveLast

Moves to the last record

MoveNext

Moves to the next record

MovePrevious

Moves to the previous record

NextRecordset

Returns the next Recordset if the query result is multiple sets

Update

Saves changes to the current record

 

 

Table 7.2

 

 

Recordset properties

 

 

 

 

 

Property

Description

 

 

BOF

Returns True if the current position in a Recordset object is

 

 

 

before the first record

 

 

Bookmark

Sets or returns the record value as a bookmark

 

 

CursorType

Sets or returns the cursor type:

 

 

 

3 – static cursor, changes made by other users are visible;

 

 

 

2 – dynamic cursor, changes made by other users are

 

 

 

invisible;

 

 

 

1 – keyset cursor, changes and deletions made by ot her

 

 

 

users are visible, additions are invisible

 

 

EOF

Returns True if the current position in a recordset object is

 

 

 

after the last record

 

 

Filter

Specifies the filter value

 

 

RecordCount

Returns the number of records in a Recordset object

 

A further evolution of ADO technology was Microsoft.NET, a development platform in the form of ADO.NET [18]. This data access

334

model was developed with emphasis placed on its applicability in Web– applications, though, further on, it will operate equally successfully also in traditional Windows applications. There are two basic features in which ADO.NET is different from its predecessor. First, it has the ability to handle data separately from the source of data, and, second, it uses the XML language for data exchange.

The first of these properties is of an extreme significance when operating data in Internet. Each connection to the server consumes its resources. When a certain number of user references to the server are made, it may have its efficiency decreased abruptly. This should be taken into account by those web-applications where the potential number of users is great. Therefore, ADO.NET connects the application to the database for a short time which is just enough to obtain a sample of information or update the database. Communication is interrupted after the data set is delivered or the command is executed, and the data obtained is further processed on the client with no communication with the server.

Use of XML as the data transmission format gives more flexibility to the applications created with the use of ADO.NET, because XML is a technical standard for transmission of data. Where an application operates in Internet/Intranet networks, it becomes no longer dependent on the client platform. Figure 7.8 gives an example of a data access model in ADO.NET.

To realize the concept of data handling separately from the data source, ADO.NET, unlike ADO, forms DataSet rather than Recordset. RecordSet represented a sample of one or more database tables as obtained using an SQL query. DataSet is a partial database copy and may consist of several tables with set relations.

To conclude the overview of data access tools, we shall look at how data objects should be selected to update current and create new applications. It is quite natural that up-to-date data access objects are employed to design new applications based on novel information technologies. However, no object model of access to data should be changed for upgrading the existing applications unless extremely necessary. This model forms the framework of the application/data communication logic so changing this will lead to the requirement of the whole application code to be rewritten.

335

Источник: https://studfile.net/preview/16708779/