Active Data Objects combines the universal nature of OLE DB - that is, it is easy to use in RDO and DAO models.
Features. ADO contains all data types that can be described by the OLE DB standard interface. In other words, ADO is expandable, do not need you
Parts do anything.
The access and manipulation of data is a inherent part of any actual application. For data, whether it is a relationship, no matter
Is there a DBMS, or no matter what it is, the data is data - a file is not necessary, it must be a given second.
Format.
Developer groups require modern development tools with simple interface to quickly access data. Microsoft's answer to this question is universal
Data Access (UDA Universal Data Access) Architecture, this, Stephen Rauch's article "Manage Data from Myriad
Detailed elaboration in Sources with the universal data access interface (MSJ, September 1997). Simple
Say, UDA is an actual theory to use OLE DB. All are pointed to a data source - an spreadsheet, an email
Message, or an AS / 400 document - filtered by the OLE DB interface and expressed in a universal format so that the application can always use the same
The way data is accessed. The intermediate layer located on the OLE DB and the call from the application is referred to as Active Data Objects.
(ADO) It is a recommended standard for writing any type of data source with OLE DB providers.
Figure 1 OLE DB
Let's take a closer look at the new features of the ADO 2.0 brought by Visual Studio 6.0. I will show you how to use Visual Studio 6.0
The kit is written in ADO. I will focus on the Java language Windows Foundation Classes (WFC) and the built-in ADO of Visual Basic.
Support for Visual C and InterDev will be slightly mentioned.
ADO overview
ADO is an object model that combines OLE DB easy to use features and in REMOTE DATA OBJECTS (RDO) and DATA.
Easy to find common feature in Access Objects (DAO). ADO is a function of access to Idispatch and vTable functions
The COM Automation Server. Most importantly: ADO contains all data types that can be described by the OLE DB standard interface. In other words,
The ADO object model has scalability, it does not need to do anything about your parts. With the usual ADO programming interface, you can
Depending on how to deal with all things, even if the format of the record set is that you have never thought about it.
ADO has been highly evaluated in its actual operation, memory coverage, thread security, distributed transaction support, web-based remote data access.
As part of the Microsoft UDA policy, ADO tries to become a standard model based on cross-platform, data source heterogeneous data access. With
The lapse of time, it will replace other models. ADO concentrated all the best features of RDO and DAO and reorganized them in one
A slightly different object model that can provide full support for the event. If you want to delve into the Microsoft data
Different from the access technology, you can take a look at "Data Access Technologies", which is written by Robert Green.
Articles on technical aspects.
Transplant your current RDO-based system into ADO does not need full reconstruction of the system, but it is not a matter of negligible things. Move
The difficulty and complexity of the planting system is much larger than RDO and ADO. It is valuable to transplantation to ADO, but I suggest that if it is absolutely necessary
If you please don't do this.
From the point of view of the company, ADO
UDA gives Windows DNA (Distributed Internet Applications Distributed Interoperability) Architecture Architecture
Access and access mechanism. To learn more about UDA, you can watch "Say Uda for All your data acess needs,"
It was written by Aaron Skonnard (see Microsoft Intective Developer, April 1998).
Even across multiple hardware platforms, any distributed enterprise system has multiple data sources, including Microsoft Access databases, spreadsheets, and SQL Server tables. Recently, I participated in a heterogeneous image database research, The content includes: SQL Server Table
(Including images and their description), classify the image by classifying the image with the name-related ASCII code and Word document, both in the owner file
There is an image and have text. When you need to deal with such a project, you will start to recognize the importance of unified methods and object public sets.
I have seen development teams using different access data methods in related projects. This situation often occurs because
One of the teams developed the child project in advance, or because they inherited some of the original code, or
The reason for the order, that is, these projects are only partially associated, and the common part between them is the underlying data, or may be a buyer. So
A team appeared with RDO to perform data operation, and another team used ADO. This is often what happens: similar to code
It was repeated twice (or more), once is RDO, once is ADO. The public layer between the project has become a physical data stored (see Figure 2).
Figure 2 Data Access Technology
The RDO before ADO is a client / server capability that increases DAO to improve its performance and expandability. Fundamentally,
RDO is a simple package located on the upper layer of ODBC API. It reveals many things in the DAO data object model, but it lacks
Data Access Jet Engine. Although this will give ADO faster speed, it can't use many of the characteristics of the engine, and it can only access the relationship
Type database.
The Thought of ADO 2.0 is to create a higher-level public layer for different applications. If you compare Figure 1
And Figure 2, you should understand what I mean. Despite the different physical locations between the data structure and the organization, the programmed interface should be the same.
In order to find more different from RDO and ADO, I suggest you read the very good article written by Bill Vaughn "Exploring
ActiveX Data Objects from an RDO Point of View, "You can find it in the technical article section of MSDN. ADO out
It doesn't mean the end of RDO. In fact, Microsoft promises to continue to support RDO in the foreseeable future.
What is the new character of ADO 2.0?
For the version of 1.5 before ADO1.5, RDO and ADO are not completely equal from the perspective of the function. The equivalent means you
Solve the same problem by these two methods; it does not me me to rename or optimize the same object. Therefore, transplantation
ADO is not a simple thing. From the other hand, once you are proficient in RDO or DAO technology, learn ADO is a considerable capacity.
Easy thing.
The new features of ADO 2.0 include event processing, continuation of record sets, hierarchical directory structures, and data forming, distributed transactions, multi-dimensional
Data, Remote Data Services (RDS), and enhancements to C and Java support. When you are drilling some Visual Basic code, you will
See all these features. When using Visual J , I will give an illustration of the new Windows Foundation Classes (WFC) is
How to support ADO's .ado's most exciting thing is that you can find it in any development tool in Visual Studio 6.0.
Full support.
ADO Quick Tutorial
The ADO object model consists of less relative number of objects. Unlike RDO object models, each primary ADO object can be created individually.
This means that for example, you don't need to create a connection before creating a valid record set object.
DIM CN AS New Adodb.Connection
DIM RS As New Adodb.Recordset
CN.Open "Biblio"
rs.open "SELECT * from Titles Where Title Like '% H'", CN
ADO 2.0 object is Connection, Command, Parameter, Recordset, Field, Error and Property.ado object model, also package
Including four categories: They are a set of related error, parameter, property and field objects. Let's take a look at each object
Main characteristics.
The Connection object provides a connection. There is a data source it is accessing in the program. The property allows you to define: connection string, command
Execution and connection start-up intervals, data providers, (whether the temporary table location should be on the client or on the server), and for
Data Access Permissions. Methods There are following features: execution commands, open, and close a connection and management transaction.
In many places you can specify the provider you want to use: By the Provider property, in the connection string, or even through the OPEN method.
Choose your favorite implementation, but to ensure that you don't specify multiple providers for the same connection. By default provider (when
You don't specify your own provider) is MSDASQL, which for the Microsoft OLE DB provider of ODBC.
Command object defines a SQL declaration, a stored procedure, or any other operation that you may want to make the provider about data.
The properties of the .command are: current connection, maximum allowable time and parameter set. A parameter is that you pass it as a parameter to the command.
Value. In these properties to distinguish between the properties of a parameter: direction (input, output, or both), the type of course is of course its value.
Recording a set object is perhaps the most typical ADO object, but it is one of the most complex. It indicates the result of the command execution, and it is large
Most of them are given in the form of a database of databases. A recordset consists of information represented by row and domain. It does not have to map
Record of relational databases. In fact, as I explained earlier, ADO is based on OLE DB and can be used to visualize.
Ask any data sources, this data source includes a non-relational database. The recordset provides buffering capabilities, which accepts data changes, and
These changes are transmitted to the server in a batch manner. You can browse and submit the contents of the record set, such as listed and extract. You also
You can modify the data in any way such as delete, add, and refresh operations. Record the strict relationship with the connection, but this does not mean
You always need an open connection to get a recordset. You can also do it as follows:
DIM RS As New Adodb.Recordset
SQL = "SELECT * from authors"
RS.Open SQL, "PUBS"
Since the connection is actually the channel transferred by the data and commands, the object is still created, except for a name called
In addition to the properties of RecordSet.ActiveConnection, it is invisible and works in the background.
The Field object is a column of data. It provides such a programming interface that allows you to make the value of a single unit and the basics
Features, such as: type and size for reading and writing. All Field objects for all given records form a field set. For example, I will
You explain, the fieldS set hides a striking property that will prove the flexibility of the Recordset object again.
Finally, the Property object. Each object has properties. The object provided by the ADO may be various. But there is no such one
Set of properties that contain all the static properties of all possible OLE DB providers. So, any ADO object has static and dynamic genus
Sex. The first set of property sets: including Name, Type, Value, and Attributes, can be accessed by the following syntax:
Obj.propertyname
The starting three attributes are self-illustrative. Attributes are a digital descriptor, which is the ability of the provider with the supplier
For some predefined properties combinations. (It is similar to the component classification of the COM server).
Dynamic properties are based on potential providers. They are assigned to the Properties collection and can be queried by name.
Obj.properties ("PropName")
The New RecordSet Object
ADO 2.0 includes some new features (see Figure 3). It is now possible to turn the recording set flatten into a string now through the getString method.
SET VARIANT = RecordSet.getstring
StringFormat,
Numrows,
ColumnDelimiter,
Rowdelimiter,
Nullexpr
)
All parameters are optional, as shown in the following code segment:
DIM RS as adodb.recordset
DIM Conn as adodb.connection
SET CONN = CreateObject ("AdoDb.Connection")
Conn.open "PUBS"
SQL = "SELECT * from authors"
SET RS = Conn.execute (SQL)
Msgbox rs.getstring (, 10)
Rs.movefirst
This routine is a familiar SQL Server Pubs database, extracting all author name into a recordset, and then
Its the most beginning of the 10 lines turn straight into a string. In addition to the Visual Basic, the value returned by getString is one
BSTR type variable structure.
When you call getString, you can schedule data in a quite different degree of freedom to arrange data by specifying parameters. For example: you can change the lack
The province's rows and columns are divided and select only the specified number of rows. Currently, the value of the StringFormat parameter can only be adclipstring,
It is the only member of StringFormatenum. The value of adclipstring is 2, which indicates that the successive parameters are valid, the library
They should take into account .Numrow is the number of rows that will be extracted from the current location. NullexPR parameters provide a selectivity
String to replace it with this string when the NULL value is encountered in the recordset.
The getString method is part of the getClipstring in the ADO. You should pay attention to something when using getString.
Love: First, the function returns flat data. No information about the structure and the description identification or any similar type table
Something. The result is that getString can be used to perform one-way data transfer, and there is no way to read back this type of word.
String. Second, getString moves the record pointer, if you want further processing, turn it back. You also have to remember the default
In the case, the method is to output the entire recordset. This means that you don't have to worry about the current record is an invalid record.
There are still other little changes in the ADO 2.0 recordset. One is an activeCommand property that returns to a given record
Set (if some of the Command object. The ADO type library defines ActiveCommand as a general class, not a Command object.
So the IntelliSense module (included in all Visual Studio 6.0 products) When writing some code that uses the properties, you
There is no use. If you add a line as follows.
Msgbox Rs.ActiveCommand.comMandText
In the previous code segment, you will be able to get the original text of the SQL declaration that produces the recordset.
Select * from authors
Bookmark
The bookmark is any value, which can uniquely identify a line in the recordset. When you need to store a reference to a specific record,
You usually need to use a bookmark. If you may guess, if you clone a recordset through the standard clone method, then the book
The sign is copied. The bookmarks provided by ADOs from different data types have little difference. If the log of record set is always a data
The library record, the bookmark may be the recorded value. This definition should be absolutely consistent, so you can exercise through simple arithmetic operation.
Compare bookmarks.
However, the source of the record can be anywhere, and the data it contains can also address different objects. In addition, the ADO programmer does not need
To know the internal structure of the data. He or she is only using it by an interface consisting of rows and domains. Let's take an example.
Microsoft Active Directory Service Interfaces (ADSI) is a role of an OLE DB provider. Because
This, it discloses ADO different kinds of objects: Services from Windows NT or Novell Directory to any Lightweight Directory
Access Protocal (LDAP) - Plastic Directory Service. In addition, the entire ADSI architecture is in contact with any directory to other directories.
The provider of the served service is working as a silent customer. In addition to these objects to perform well-known and predefined
Programming interface, this is said that ADSI itself is such a public object, which does not know the details of any ADO application.
There is a bookmark that is used to identify one of these objects. ADO applications, and those such as ADSI do not know.
It. Bookmark must be directly managed by the provider. ADO handles bookmarks through the OLE DB IROWSETLOCATE interface.
Support bookmarks, it must implement the interface properly.
DIM Vbookmark As Variant
Rs.cursorlocation = aduseclient
Vbookmark = rs.bookmark
.
Rs.bookmark = vbookmark
This code describes how to use bookmarks in your code. Use the pointer type that supports bookmarks is an important thing. Bookmark is
A readable and writable properties, you can assign it to any value, including continuous characters.
Rs.bookmark = "Hello, World"
If you want to run a message when you use the parameters used by the program's bookmark when you run in Visual Basic 6.0.
Show. But the actual value of the bookmark should always be invisible to the user's application.
If you need a comparison bookmark, you must use the CompareBookmark function provided by the Recordset object exposed in ADO 2.0. This
Functions and bookmark properties themselves are directly mapped to the iRowSetLocate function. In particular, the positioning method of the interface is as: Compare,
GetRowSat and GetRowsbyBookmark, their names have self-explanatory. Figure 4 shows the world's world's use of recorded objects
The simplest Visual Basic code with new features.
The record set has been filtered before ADO 2.0 capability, but version 2.0 also adds to find and classify features. Basically, Sort properties
The order of the rows that affect the way to record the collection tree and the traversed rows. The Filter property determines which lines are visible to the user. Use
The mask is given by a column Boolean or by a bookmark array. You can also use wildcards. Finally, the Find method retrieves based on finding the address field.
One line. The grammar of thefind method is:
Find (criteria, Skiprow, SearchDirection, START)
The criterion of the search is a string according to the following format:
All Boolean Operations will be possible. The criterion string is as follows:
City = 'redmond'
and
Name Like 'Bill *'
There are also some stringent grammar requirements. The date value must be attached to a pair of # characters, and the single quotes must be surrounded by strings.
The Find command line allows you to skip a given number before starting to find it. Initial location (and the location you started to jump) is
START parameters. SearchDirctiion determines the lookup is the top or bottom it. You can do something to speed up
The speed of processing. First, set the AduseClient pointer to set the Optimize dynamic property of the domain you want to retrieve. True.
FieldName.properties ("Optimize") = true
This way, can retrieve and access the domain faster. Note that Optimize is not the provider's properties. It is only defined within ADO
And use. This property is only added to the Properties collection only when the AsuseClient pointer is set.
Continuation and buffering of record set
A few months ago, a reader sent me an email, there is a very strange problem in this. He said, "I like the record set.
Structure, and I use them at any time. ADO record set can be used to make buffers for data without need to involve database
Connection or, even OLE DB providers? "I quickly answered this:" No, I don't think you can do this. No matter how you recorded
Need a connection. "
Through further thinking, I think he said the most important issue. Ado record set is a flexible, optimal data structure. It
We can work well with the OLE DB database, but unfortunately, you can't do anything that you need a powerful use.
Use them when it is. But there is a good news. ADO 2.0 gives you a new feature for this problem. Field set provided
Quite new Append method, it can create a recordset in the original.
DIM RS As New Adodb.Recordset
Rs.cursorlocation = aduseclient
Rs.fields.Append "name", Adbstr
Rs.fields.Append "City", Adbstr
RS.Open
Rs.addnew
RS! Name = "Dinoe"
RS! City = "redmond"
Here is an ADO recordset, which has no database connection and OLE DB concept. ADO record set is always a separate object.
Tight is the customer pointer you choose and add your new domain to the field of the field. It is required to need two .Append method needs two
Non-selective parameters: domain names and types. If you want a string, use Adbstr.
If this is the case, imagine that it is a direct approach. For example, you can write the code to read your old owner file
And turn their data to the record set.
This is just a method of created a recordset by a disk file. ADO 2.0 adds support for the continuity of records. In fact, you have
A new way known as save, with two parameters: output file name and data format.
DIM RS As New Adodb.Recordset
Rs.aduseclient
Rs.save "C: Demo.rst", Adpersistadtg
Currently, only Adpersistadtg (that is, zero) is allowed. Only open record sets can be stored. Store data can also
It will be affected by the filter you use. Note that the method does not turn off the file before the recording set is closed. In this middle, the file is
Access to read-only mode. This makes the ADO application to create parallel with Save methods, and the continued buffer is easier. If
The file already exists, and the Save method returns an error and ready to perform a working environment. Moreover, the method will be the position of the current line
Move to the first record. It saves all the things related to the record set (including data, and chart) to disk. However, it is not
Store connection and command information. This is distinguished from Save and getString and allows the application to load a previously stored recordset.
The method used is:
Rs.Open "C: demo.rst"
Again again: Using the client finger is important for you.
Asynchronous acquisition and event processing
ADO 2.0 also allows you to execute commands in this way: that is, you get data asynchronously. This happens in the syntax of the Open method.
Recordset.open Source, ActiveConnection, Cursortype,
LockType, Options
As usual, the Source parameter is specified for a valid SQL string (or even a name that is stored), one first
The name of the previously stored file, or a Command object .Options parameter limit command, and may affect the provider to handle it
The way. In particular, it can set the value of adexecuteasync or adj refacthchasync.adfetchaysnc means Source command must
It must be performed in asynchronously, that is, the method is immediately returned and the provider activates an event at the end of the operation.
On the one hand, the ADFETCHASYNC makes the rows in the first block are synchronously removed (as usual). The size is concentrated by the record
The value stored in the Cachesize property is determined. The remaining lines are loaded asynchronously.
When a software runs asynchronously, the platform should provide a way to make the user know when it ends. For this issue
Different implementation methods, Platform SDK uses synchronous objects, Microsoft Internet Explorer Remote Scripting
Using a callback function. ADO selected a third method, perhaps the most appropriate method for the RAD programmer: event.
There are two types of events in this: Events related to the Connection object (ConnectionEvent interface) and belonging to the Recordset object.
(RecordEvent interface) (see Figure 5). In many cases your program will be notified before and after a specific operation. In one
Events caused after operation are always accompanied by an Error object to describe the results of the operation. Events triggered before operation
You can control the parameters of the next command. Events that may arrive at your application will be too frequent. By correcting the status parameters of an event, you can avoid further notifications.
Willchangefield Cfields, Fields, Adstatus, Precordset
The cfields parameter is the number of Field objects in the next fields array. Fields contains Field pairs with hangs
Icon. Related records are maintained through the PrecordSet parameter .Adstatus is a type eventStatusenum object, its value
Usually set to adstusok. It is set to:
Set adstatus = adstatusnunwantedevent
If you don't want to do this again.
Processing ADO events may be easy, which will depend on the language you are using. As you may guess, you can use Visual C when you
The connection pointer should be obtained from the library and call it. This requires you to have considerable programming in your code part, but will
Give you a lot of flexibility. In fact, you can define a simple handle process handle with multiple objects. On the other hand, all
The method in the output interface must be executed, even with the simplest statement:
Return S_OK;
Compared with Visual C , Visual Basic and Visual J saves you some work. Especially Visual Basic asks you
Each object writes a corresponding event processing, which is because the event processing process is based on the name. Using the WitHevents keyword is
Get the best way to get an event in Visual Basic. (If you use Visual C , WitHevent will be used by you.
Visual C implemented features may be different)
Visual J follows a slight different implementation method: it is a Listener-based event model from Java languages.
Generally speaking, you need to define a class to perform an output interface and attach this class to an instance of the class that triggers event. This is the bottom limit
Degree requirements. By supporting Ado 2.0 built-in support, WFC is greatly simplified. It uses Visual Basic
Simple, but far more simple than Visual C .
ConnectionEventHandler Handler = New
ConnectionEventHandler (this, "onConnectComplete");
Previous segments define a class in the ConnectionEvent interface to perform an onconnectComplete event. You will follow you
The "Listener" function is added to the event processing of the object.
Connection conn = new connection ();
Conn.AddonConnectComplete (Handler);
Thus, you have multiple processing for the same event.
Layered directory structure pointer and data forming
If you handle data, then you are likely to extract it from multiple tables. In most cases, you use the join command merge
Data in the related table, especially in the case of your access to the relational database. Any record set formed by the Jion command always contains
Excess information. For example, if you are interested in all books of an author, you can merge Authors and Title Authi tables.
(I hereby refer to Biblio and Pubs database). In the returned record set, the author's information is invalidated in each row.
The more the number of nested times you merge, the more complex, eliminate excess information, the more important for you, the layered directory structure pointers allow you to base
The logic of the tree can organize your record set. This process is also called data forming, and it can be implemented in two ways. You can use
Similar to the forming language of SQL, or you can use the corresponding advanced tools of Visual Studio 6.0. I will provide it later.
An example. Now let's take a look at the forming language.
In some way, the forming language seems to be similar to the SQL language.
Shape {SELECT AU_ID, Author from authors}
Append ({SELECT ISBN from "
As chapter relate au_id to au_id) Generally speaking, the shape command defines a recordset, an Append clause Add a sub-recordset to it. In other words, records can
Use other data types as a domain. (See Figure 6). The parent record set and sub-record set is achieved through the relationship between the domain and the domain.
Connect, this relationship also needs a name.
Figure 6 Append record set
As the result of the data forming, the parent record set adds a new column. New domains in each row point to defined in the Append clause.
The subcordset set. The sub-record set also lists the same domains in the AU_ID value with the form of the father record. In the previous code,
If you give an author's id, there is a recordset, there is a added domain called Chapter, its Value
Sexuality is pointing to a sub-recordset, which has a set of all requested domains from the Title Autor table, in this case,
Is ISBN. Figure 7 illustrates some Visual Basic source code for positioning of the layered directory structure record. Note how I?
Access the Chapter field by name. In order to get the actual sub-recordset, another step is needed: call the value attribute.
The shape command can also be nested. This means you can use other shape commands as an internal command of the Append. Sworthy Shape Syntax
The road is also an annoying thing like manual writing SQL query. Fortunately, Visual Studio 6.0 provides you with advanced work.
It can significantly simplify Shape queries. I will briefly describe this.
Append is not the only one you can attach to the SHAPE command. You can also use a Compute clause instead .compute
Enable you to perform statistical functions for existing rows, or packet in one or more domains. Its predefined functions have SUM, AVG, MAX, and
MIN. The results of these operations of the Father are given in the final record set. Moreover, the record set also includes a reference domain, which pointing
The actual table in which the original line is processed by Compute. Do you think I don't understand? Let's take a look at an example.
Suppose you have a customer order. One day, you want to know that each surname is the total number of orders that start with A.
Shape {SELECT CUSTID, LAST NAME
From Orders Where Last Name
Like 'a%' '}
Compute (SUM (AMOUNT) AS
Chapter
By Custid
Figure 8 illustrates the result record set. You have the total number of users' ID, last name, and orders, except for the list of customer orders, others are shaped
Very simple.
Figure 8 Compte record set
In order to achieve data forming function at the bottom level (that is, without using a special tool), you have to specify your provider
Msdatashape.
DIM CNN As New Adodb.Connection
CNN.Provider = "msdatashape"
CNN.Open "Biblio"
Visual Basic 6.0 Data Environment Designer
One of the most striking new features of Visual Basic 6.0 is the Data Environment Designer Data Environment Designer
(See Figure 9). It is a general, design-time environment, which allows you to arrange three types of data tools: connection, command and remember
Colon is also an object. You can include it in your Visual Basic project and in your code.
Quote it. (See Figure 10).
Figure 9 Data ENVIRONMENT Designer
To add an instance to the project, you only need to select Project | Add Data Environment. So you can like any other
That is to handle it. The only difference is that it is an object that is valid throughout the project, not specializes in one.
A given form.
Figure 10 Data Environment Object Model (Data Environment Object Model)
The Data Environment object model consists of three collection: commands, connections, and records, of course
Plus some universal properties such as Object and Name. You can embed an object into your engineering group, and use it to prepare any you
Data connection and query required at runtime. Data environment blurred the difference in SQL query language and Shape language. You can simply define the command and you can graphically do this. (See Figure 11). That is, This should be made by the following environment.
Figure 11 Create a query
Here, there are wizards, dialogs, and toolbar buttons to help you create any type of record set. For example, in Figure 9, you can see two
Different connections, they are followed by a Microsoft Access database (through the OLE provider for ODBC) and a SQL Server
Table connection. From the designer's position, the creation method of the two records is exactly the same. The existence of nested command objects has caused here.
The column of the hierarchical directory structure. You can add subcommands through the context menu, as shown in Figure 12. Defining a new connection is like compling
As simple as the instructions in Figure 13.
Figure 12 Add a subcommand
Figure 13 Create a new connection
You can create an object in a variety of ways in the Data Environment Designer environment. For example, you can set up from new
ADODC control to the DataSource properties of any data of MSFlexGrid. Second, you can take advantage of its object model
And directly access any predefined connections, commands, and records. You can also add some code, it's on the ADO object and DataENVIRONMENT
Initialization and termination respond. To do this, just select the DataEnvironment object in the Project View window,
And switch to code (see Figure 14)
Figure 14 Treatment ADO event
In Visual Basic 6.0, Data Environment Designer works with the DataView window, and the IDE tool is allowed.
Make You view the internal structure of any data source and you can also create a new data connection.
Write ADO in different environments
When writing ADOs with Visual Basic 6.0, you cannot ignore the Hierarchical FlexGrid (see Figure 15 shown in Figure 15.
Figure 15 Hierchical FlexGrid
It is obviously much better than the original version of Visual Basic's FlexGrid control. It has a new feature that hints like a name: built-in pair
Support for record sets of the hierarchical directory structure. Figure 16 shows a simple Visual Basic 6.0 program, which is used
HflexGrid controls and outline the features of all ADOs I have now involved. In this example, I defined one
DataENVIRONMENT objects and use it to get a recordset from the Biblio containing all the books of an author.
The lack of connection between the Data Environment key and the HFlexGrid control can be found in this clip.
Figure 16 Demo
Private subdddataenv_click ()
Set hflex.datasource =
DataENV
Set hflex.DataMember =
DataENV.RecordsetName
End Sub
This code automatically defines the DataEnvironment object, which is the data source that will be defined as a HFLExGrid control.
The HFlexGrid control can also be successful for displaying a planar recordset and is functional as the original version of Visual Basic.
You can use the new ActiveX control of Msadodc.ocx to make the ADO's functionality. It looks like earlier but current
The DATA control that is still supported. Adodc is assumed to replace the Data control after you like it. If you may guess,
The ADODC has the characteristics of the DATA control. It is based on OLE DB and discloses an ADO 2.0 programming interface.
Figure 17 AdodC control
In Visual Studio 6.0, Visual InterDev is a major web development tool. It has two specializes: DATA
Environment object (the same thing can be found in Visual Basic) and Recordset design when designing. This idea is
Simple, add Data Environment object to the project, define your data connection, query, and complete the other you need.
What work. When you are finished, you will insert the RecordSet design to insert your Active Server Pagers and extract the data objects you need from DataEnvironment collection - RecordSets, Commands, Connections (recordset,
Command and connection).
Function initrs ()
{
Thispage.created;
Var Rstemp = de.recordsets ('authors');
Rsauthors.setRecordSource (RSTEMP);
Rsauthors.open ();
}
The previous code segment illustrates a JavaScript process, which restores a recordset and opens it in the page.
Using ADO under C , and typically use advanced object models from C , often causing the following problems, you need to return the method.
The Variant type converts a local type of language. Due to this reason, Ado 2.0 is open to iadorecordbinding.
The interface allows you to bind a specific type of record set to a C type. This can be done by following:
Define a class from CadorecordBinding and declare it in header file Irsint.h. This class must have the following three
Method: Bindtorecordset, addNew, and Update.
Add as many required data as possible to the class to map the domain of records. By using one of the following predefined macros
Bind each recorded domain with its corresponding data member, ado_variable_length_binding_entry,
ADO_FIXED_LENGTH_BINDING_ENTRY and ADO_NUMERIC_BINDING_ENTRY. All of these to macro must be
The following is surrounded.
Begin_ado_binding
END_ADO_BINDING
When you get a recordset, call the bindtorecordset, pass his pointer to your class.
Now, according to your needs, you need to handle the record set. Important is from now, you can start your own data, not right
The source data of the record set is processed. Every time you move the current location, the data will be automatically extracted and put it in C
Example variables.
There is also the same problem in the Java language, and in Visual J 6.0, this is to solve this by introducing additional methods in Field.
problem.
In the Visual J 6.0 environment, data access is simple in Java language. New Visual J
The WFC includes some special dedicated classes for data management. The result is written in the Java language to write a database application.
It is much easier than before.
Let's review the situation of Visual J 1.1. You can call the ADO 1.5 object model, but you must be implemented through COM
This. Due to the factors of the Java / COM integration model, you need to have one between your Java-based programs and hopes COM servers.
Set of interfaces. In this way, Microsoft Java Visual Machine can hill these interfaces and redirect them to actual services.
On the instrument. You also need a Java Type Library Wizard (Java Type Library, Javatlb.exe or Jcom.exe)
Tools to help you generate all packaging classes. The last step is to call Visual J Database Wizard to complete your job.
It is completely different from Visual J 6.0 and WFC. Now the class library has three objects, named: Connection,
Command and RecordSet. Their method and attributes follow me the ADO object model discussed earlier. ADO event also
You can follow the typical listener JDK model.
Most importantly, the programmer's job is just written Java code - do not need to consider tools, wizards, and middle class. The following is an example of how to establish a connection and open a recordset.
Void OpenDataConnection () {
m_con = new connection ();
m_rs = new recordset ();
m_con.setConnectionstring
"Provider = msdasql.1; uid = sa;
PWD =; Database = PUBS; DSN = SQLS; Server = (local); ");
m_con.setcursorLocation
Adoenums.cursorLocation.Client);
m_con.open ();
m_rs.setactiveConnection (m_con);
M_rs.setSource ("Select * from authors");
m_rs.setcursortype (adoenums.cursortype.static);
M_rs.setcursorLocation
Adoenums.cursorLocation.Client);
m_rs.setlockType (AdoEnums.lockType.Optimistic);
m_rs.open ();
}
Visual J also provides you with four-faceted components: DataSource, DataBinder, DataNavigator and DataGrid.
DataSource implements a database of a database, while the DataBinder implemented features like a group of UI controls. These components are
The front position changes automatically. DataBinder is connected to the specific DataSource. Datanavigator and Visual Basic
The DATA control is very similar (even if the user interface is also very similar), and the DataGrid is a typical data source-based grid.
This is an overview that is about this: WFC class library based on Java language is about data access using ADO 2.0.
Related content. Visual J also uses the wizard to make it easy to use Java development framework database applications.
ADO of the web
Last year, when Internet Explorer 4.0 is released, few programmers really understand the importance of data binding features. This feature looks
Great, but it relies on Internet Explorer 4.0 and lacks appropriate examples and applications. Data binding is a web-based Web
Technologies that allows you to leave the current page to access remote data sources. In other words, data binding is the Web version of the data specifese control. If
You use it, you can let the data bind the HTML tag. For example, you can connect a