Presentation is loading. Please wait.

Presentation is loading. Please wait.

What’s new in ADO 2.5 Greg Hinkel Program Manager Data Access Group

Similar presentations


Presentation on theme: "What’s new in ADO 2.5 Greg Hinkel Program Manager Data Access Group"— Presentation transcript:

1 What’s new in ADO 2.5 Greg Hinkel Program Manager Data Access Group greghin@microsoft.com

2

3 Agenda  ADO - Overview  Semi-structured Data  URL binding for ADO Objects  Record Object  Stream Object  Performance and XML  Summary  Feedback and Information

4 ADO Overview  A single, powerful consumer interface for data exposed by OLE DB providers  For use in Web-based, Client/Server and distributed applications  Works with many languages (Visual Basic ®, Visual C++ ®, Visual J++ ™, Visual Basic Scripting Edition)  High Performance  Simple Object Model

5 MDAC Components MDAC OLEDB Core Services IIS / VS / IE / MTS / ETC Backend Data Store Mainframe / RDBMS / Directory Email & Messageing / File System ASP / ISAPI ADO Oracle SQL Server ODBC ODBC Drivers - SQL Server - Oracle - Etc XML OLEDB Providers Shape Provider

6 Semi-structured data  Data that is: More structured than a BLOB More structured than a BLOB Structured differently than a relational database table Structured differently than a relational database table  Examples: A file system A file system Email data Email data Web pages Web pages

7 Semi-structured data  Data that may be organized hierarchically, like a tree Can have arbitrary depth Can have arbitrary depth  Each node in the tree has a set of properties Each node may have a different set of properties Each node may have a different set of properties  Leaf-nodes associated with a special “Value” property  Non-leaf nodes are collections of other nodes

8 Semi-structured Requirements  Node Operations Get/Set properties, Add/Delete properties Get/Set properties, Add/Delete properties  Scoped Operations Move, Copy, Delete operations apply to all contained nodes Move, Copy, Delete operations apply to all contained nodes  Querying A list of nodes that satisfy a predicate on properties A list of nodes that satisfy a predicate on properties  Lightweight Operations such as reading email properties, etc. are done many times Operations such as reading email properties, etc. are done many times

9 ADO 2.5 - Design Goals  Keep it simple!  Allow ADO objects to be opened with URL strings  Extend ADO to work with hierarchical data sources  Provide the ability to do scoped operations  Extend ADO so that it may be used to read and manipulate binary streams

10 Modeling semi-structured data with ADO 2.5  Collections are modeled as recordsets Common properties are modeled as fields of the recordset Common properties are modeled as fields of the recordset Folders, Directories Folders, Directories  Nodes are modeled as a record object Properties are modeled as fields of the record object Properties are modeled as fields of the record object Files, Email folder objects Files, Email folder objects  Contents of a record can be manipulated by the Stream object

11 Semi-Structured Data in MDAC 2.5 Semi-Structured Data ResourcesCollectionsProperties OLE DB 2.5 RowRowsetColumns ADO 2.5 RecordRecordsetFields

12 ADO 2.1 - Object Model Connection Command Recordset Errors Parameters

13 ADO 2.5 - Object Model Connection Command Recordset Errors Fields Parameters RecordStream

14 URL Naming for ADO  URLs can be used to directly identify objects in a data source nodes in a hierarchical namespace (files and folders) nodes in a hierarchical namespace (files and folders) table in a relational database, unique rows in a table table in a relational database, unique rows in a table  Record object represents a unique object file, folder, table, row file, folder, table, row  Recordset object represents the contents of a collection object rows of a table, files in a folder rows of a table, files in a folder

15 URL binding in ADO 2.5  ADO 2.5 allows URL naming for Connection, Recordset, Record, and Stream objects Connection, Recordset, Record, and Stream objects For a Recordset, URL must point to a collection type node For a Recordset, URL must point to a collection type node For stream, URL must point to an object with a default stream defined For stream, URL must point to an object with a default stream defined  The RootBinder cracks URLs and calls the right provider  New record objects can also be created directly

16 URL naming - sample code Sub main() Dim conn As New Connection Dim rec As New Record, rec2 As New Record Dim rec As New Record, rec2 As New Record ‘open a connection and then the record ‘URL= in the connection string conn.Open "URL=http://adot20/davfs/greghin" conn.Open "URL=http://adot20/davfs/greghin" rec.Open "TestFolder", conn rec.Open "TestFolder", conn ‘open record with implicit connection object ‘URL= only in the connection string rec2.Open " TestFolder ", _ "URL=http://adot20/davfs/greghin/“ End Sub

17 Record Object (1 of 2)  New automation object implemented in ADO 2.5  Models an entity that has a collection of properties and (possibly) nested entities Email, Files, web pages, structured documents, folders, Databases, Tables, etc. Email, Files, web pages, structured documents, folders, Databases, Tables, etc. can also represent a row of a recordset can also represent a row of a recordset Email/File contents appear as a stream property Email/File contents appear as a stream property

18 Record Object (2 of 2)  Expresses the notion of containment & scoping Folders contain other folders and files Folders contain other folders and files Folder operations such as move, copy, etc. apply within the folder’s scope Folder operations such as move, copy, etc. apply within the folder’s scope  Properties are modeled as a collection of Fields  Containment is modeled as Sub-Records Records can be viewed in a tabular form as a recordset Records can be viewed in a tabular form as a recordset  Properties and methods are implemented to operate on the record object

19 Opening a Record Object   Many ways to open a record object Open directly using a URL that uniquely identifies it From an ADO recordset by specifying an individual record From a field’s value property  Record object always exists in the context of a Connection object connection object is either implicitly created or explicitly specified connection object is either implicitly created or explicitly specified

20 Record Properties

21 Record Methods

22 The Record Object ‘opens an existing record object or creates a new one Sub OpenFolderIfExists() Dim rec As New Record Dim rs As Recordset Dim rs As Recordset rec.Open "TestFolder", _ "URL=http://adot20/davfs/greghin/“ rec.Open "TestFolder", _ "URL=http://adot20/davfs/greghin/“ if rec.RecordType = adRecCollection then if rec.RecordType = adRecCollection then Set rs = rec.GetChildren Set rs = rec.GetChildren ‘do stuff with recordset end if End Sub

23 Fields of a Record object  A field represents a property associated with a record object Title, size, modified time of a file, folder, email message Title, size, modified time of a file, folder, email message  Fields are implemented as a collection on the record object  Methods and properties are same as that on recordset’s field object  New fields can be added to the collection of an already open record object

24 Working with the Fields collection Sub RSFields() Dim rec As New Record Dim fld As Field Dim fld As Field rec.Open "greghin", "URL=http://adot20/davfs" rec.Open "greghin", "URL=http://adot20/davfs" ‘use For Each to loop all the fields ‘use For Each to loop all the fields For Each fld In rec.Fields Debug.Print fld.Name, " = ", fld.Value Debug.Print fld.Name, " = ", fld.Value Next Next End Sub

25 The Recordset Object  When a record is a collection (such as a folder), it has other records contained in it  A view of contained records is available as a recordset tabular view as opposed to the tree view tabular view as opposed to the tree view  Use GetChildren method on the Record object opens the default contents recordset - pre- defined schema for document source providers opens the default contents recordset - pre- defined schema for document source providers  Execute a command against a folder Ability to search on properties Ability to search on properties  Use Record and Recordset for navigation URL is one of the fields on the contents recordset & can be used to open the contained records URL is one of the fields on the contents recordset & can be used to open the contained records

26 Recordsets with Variable # of Columns  Many data sources generate recordsets where each row has a different set of columns  Case in point: Contents of a mail folder An email folder has different properties from the Contacts folder An email folder has different properties from the Contacts folder  Case in point: An XML stream Each element may have a different set of attributes Each element may have a different set of attributes  Case in point: The Contents recordset Each file in a folder has different set of properties Each file in a folder has different set of properties

27 Supporting Variable Column Recordsets  The fields collection on the recordset contains the set of “common” fields From address, subject, receive date, etc. for email From address, subject, receive date, etc. for email File name, size, last modified, etc. for files File name, size, last modified, etc. for files  Each record has a set of fields unique to that row This is a superset of the common columns that exist for the recordset This is a superset of the common columns that exist for the recordset  To view the variable fields, obtain a record object from the recordset and then use its fields collection

28 Relationship between the Record & Recordset Objects  Record’s field collection Superset of the fields collection on the associated source recordset, if any Superset of the fields collection on the associated source recordset, if any  It is possible to add/delete fields from an already open record object only for fields that are unique to that record only for fields that are unique to that record  Record behaves in the same update mode as its source recordset if no source recordset, then in immediate update mode if no source recordset, then in immediate update mode

29 Working with the Recordset Object Sub OpenRecordset() Dim rs As New Recordset Dim rec As New Record Dim rec As New Record rs.Open "greghin", "URL=http://adot20/davfs", _ rs.Open "greghin", "URL=http://adot20/davfs", _,, adCmdTableDirect,, adCmdTableDirect While Not rs.EOF While Not rs.EOF rec.Open rs rec.Open rs Debug.Print rec("RESOURCE_PARSENAME").Name Debug.Print rec("RESOURCE_PARSENAME").Name rec.Close rec.Close rs.MoveNext rs.MoveNext Wend Wend End Sub

30 Stream Object  An automation object used to manipulate the contents of a binary or textual stream  Implemented on top of IStream interface  Record objects usually have a default stream associated with them content of an email message, default document for a web folder content of an email message, default document for a web folder  BLOB/Text fields in a database may also be viewed as a stream object

31 Stream Properties (1 of 2) Charset: Specifies the character set into which the contents of a text Stream should be translated Charset: Specifies the character set into which the contents of a text Stream should be translated EOS: Identifies whether the current position is at the end of the stream EOS: Identifies whether the current position is at the end of the stream LineSeparator: Specifies the character to be used as the line separator in a text stream LineSeparator: Specifies the character to be used as the line separator in a text stream Mode: Indicates the available permissions for modifying data in a Stream object Mode: Indicates the available permissions for modifying data in a Stream object

32 Stream Properties (2 of 2) Position: Specifies the current position within a Stream object Position: Specifies the current position within a Stream object Size: Indicates the total size of the stream in number of bytes Size: Indicates the total size of the stream in number of bytes State: Indicates whether the object is open or closed State: Indicates whether the object is open or closed Type: Identifies the type of data contained in the Stream (binary or text) Type: Identifies the type of data contained in the Stream (binary or text)

33 Stream Methods (1 of 2) Cancel: Cancels an asynchronous operation on the stream object Cancel: Cancels an asynchronous operation on the stream object Close: Take a guess Close: Take a guess CopyTo: Copies a specified number of bytes from a stream to another stream object CopyTo: Copies a specified number of bytes from a stream to another stream object Flush: Forces the contents of the Stream remaining in the ADO buffer to the underlying object with which the Stream is associated Flush: Forces the contents of the Stream remaining in the ADO buffer to the underlying object with which the Stream is associated LoadFromFile: Loads the contents of a file by reading in data from an existing file LoadFromFile: Loads the contents of a file by reading in data from an existing file Open: Opens a Stream object to manipulate streams of binary or text data Open: Opens a Stream object to manipulate streams of binary or text data

34 Stream Methods (2 of 2) Read : Reads a specified number of bytes from a Stream object Read : Reads a specified number of bytes from a Stream object ReadText : Reads specified number of characters from a text Stream object ReadText : Reads specified number of characters from a text Stream object SaveToFile : Saves the contents of a stream into a specified file SetEOS : Sets the position that is the end of the stream SetEOS : Sets the position that is the end of the stream SkipLine : Skips one entire line when reading a text stream SkipLine : Skips one entire line when reading a text stream Write : Writes binary data to a Stream object Write : Writes binary data to a Stream object WriteText : Writes a specified text string to a Stream object WriteText : Writes a specified text string to a Stream object

35 Working with the Stream object Sub StrmOperations() Dim strm As New Stream strm.Open "URL=http://adot20/davfs/greghin/some.doc" strm.Open "URL=http://adot20/davfs/greghin/some.doc" Debug.Print strm.Size Debug.Print strm.Size Debug.Print strm.Type 'adStructDoc = 2 Debug.Print strm.Type 'adStructDoc = 2 Debug.Print strm.ReadText Debug.Print strm.ReadText Debug.Print strm.Charset 'Unicode Debug.Print strm.Charset 'Unicode strm.SaveToFile "C:\CopyOfDoc.doc" strm.SaveToFile "C:\CopyOfDoc.doc" End Sub

36 Performance  ADO 2.5 is faster than ADO 2.1  We improved our performance for scripting languages  Much better on multiple processor machines

37 XML  ASP rs.Save Response, adPersistXML rs.Save Response, adPersistXML rs.Open Request rs.Open Request  File rs.Save “C:\authors.xml”, adPersistXML rs.Save “C:\authors.xml”, adPersistXML rs.Open “C:\authors.xml”, adPersistXML rs.Open “C:\authors.xml”, adPersistXML  Stream rs.Save strm, adPersistXML rs.Save strm, adPersistXML rs.Open strm rs.Open strm

38 ADO 2.5 - Summary  Extends ADO to work with semi- structured data exposed by new data sources  Enables web-publishing and document management through scripting languages  Shipping MDAC 2.5 with Windows 2000 Available in Beta3 Available in Beta3

39 Feedback and Information Newsgroups and web site:  http://www.microsoft.com/data/  microsoft.public.data.oledb  microsoft.public.data.ado  microsoft.public.data.ado.rds Feedback  MDAC: mdac@microsoft.com  ADO: adodoc@microsoft.com  OLE DB: oledbdoc@microsoft.com  ODBC: odbcdoc@microsoft.com

40


Download ppt "What’s new in ADO 2.5 Greg Hinkel Program Manager Data Access Group"

Similar presentations


Ads by Google