SlideShare a Scribd company logo
OLE DB 2.0 ARCHITECTURE
Arun Seetharaman
Computer Call
January 20, 1999
OLE DB 2.0 Architecture - Supporting Remote Data Exchange
Data
access
WINDOWS DNA DATA
ACCESS
AGENDA
➔Review of OLE DB object model
• New in OLE DB 2.0
• Connecting to OLE DB data sources
• Navigating hierarchical data
• OLE DB service components
• Questions and answers
DATA AS A
COMMON ABSTRACTION
• Common representation of data
• Code/knowledge reuse
• Tools can access data generically
• Generic components can add functionality
• Components can combine different types of
data
◆ Sharing data
⚫ Reduces memory footprint
⚫ Reduces data movement
⚫ Better component coordination
TERMINOLOGIES
• Data Provider
• Software that implements OLEDB Interfaces
• Exposes data in a tabular form
◆ Consumer
⚫ Consumes the data
◆ Service Provider
⚫ Consumes data exposed by Data Provider
⚫ Transforms and provides data
OLE DB DESIGN PHILOSOPHY
• Data stores provide interfaces to
native functionality
• Data store is not required to
implement extended functionality
◆ Consumers assume common functionality
⚫ Consumers don't need excess conditional code
◆ “Service components” augment data store's
native functionality
⚫ Generic, reusable components provide a guaranteed
level of interoperability
Data source
IDBCreateSession
Rowset
OpenRowset()
Rowset
Execute()
OLE DB OBJECT MODEL
ICommand
Command
CreateCommand()
IDBCreateCommand
IOpenRowset
Session
CreateSession()
AGENDA
Review of OLE DB object model
➔New in OLE DB 2.0
➔Connecting to OLE DB data sources
• Navigating hierarchical data
• OLE DB service components
• Questions and answers
CONNECTING TO
A DATA SOURCE
BEFORE 2.0
• Via root enumerator
• Passing provider’s CLSID to CoCreateInstance
• Hard-code provider CLSIDs
• Obtain CLSID via application specific code
◆ Disadvantages:
⚫ No common UI
⚫ No common way to represent or persist
connection information
CONNECTING TO
A DATA SOURCE
OLE DB 2.0
• OLE DB 2.0 provides common services to
connect to data sources:
• IDataInitialize
• Persists connection strings
• Leverages OLE DB services
(More on this later…)
• IDBPromptInitialize
• Uses the data links UI
• Manages data source properties and data link
(*.UDL) files
WHAT CAN I DO WITH
IDATAINITIALIZE ?
• Modify sample consumer
to use IDataInitialize
• Instantiate the OLE DB initialization service
CLSID_MSDAINITIALIZE
One simple change to current code
• Create a Data Source object via
IDataInitialize::CreateDBInstance
// Create the Initialization Component
hr = CoCreateInstance( CLSID_MSDAINITIALIZE, NULL,
CLSCTX_INPROC_SERVER,
IID_IDataInitialize, (void **)&pIDataInit);
if (FAILED(hr))
{… }
// Create an instance of the OLE DB provider for Jet
hr = pIDataInit->CreateDBInstance( CLSID_JETOLEDB_3_51,
NULL, CLSCTX_INPROC_SERVER,
NULL, IID_IDBInitialize, (IUnknown**) &pIDBInit);
if (FAILED(hr))
{… }
WHAT ELSE CAN I DO
WITH IDATAINITIALIZE?
• Given a data source, retrieve a connection string
• GetInitializationString
• Persist a connection string
• WriteStringToStorage
// Use IDataInitialize::GetInitializationString to return connection
string
hr = pIDataInit->GetInitializationString( (IUnknown*)pIDBInit, TRUE,
&pwszInitString);
if (FAILED(hr))
{… }
// Use IDataInitialize::WriteStringToStorage to persist connection string
hr = pIDataInit->WriteStringToStorage(pwszFileName, pwszInitString,
CREATE_ALWAYS);
if (FAILED(hr))
{… }
WHAT ELSE CAN I DO
WITH IDATAINITIALIZE?
• Persist a connection string
• LoadStringFromStorage
• Given a connection string, instantiate a data source object
• GetDataSource
//Create the Initialization Component
hr = CoCreateInstance( CLSID_MSDAINITIALIZE, NULL,
CLSCTX_INPROC_SERVER, IID_IDataInitialize,
(void **)&pIDataInit);
if (FAILED(hr))
{… }
// Read the initialization info from previous example
hr = pIDataInit->LoadStringFromStorage(pwszFileName,
&pwszInitString);
if (FAILED(hr))
{… }
// Create a Data Source object using the initialization string
hr = pIDataInit->GetDataSource(NULL, CLSCTX_INPROC_SERVER,
pwszInitString,IID_IDBInitialize, (IUnknown**) &pIDBInit);
if (FAILED(hr))
{… }
DATA LINKS
• Common UI for data sources
• Can be used by any application
• Reflects properties of the provider
• Connection information can be persisted as “Data links”
Data links can be used from ADO or OLE DB
Invoked from desktop
IDBPROMPTINITIALIZE
• Program access to the Data Links service
• PromptDataSource
• Opens data link properties dialog
• Returns a data link with properties
• PromptFileName
• Opens Select data link dialog
• Returns path to data link (*.UDL) file
DATA LINKS EXAMPLE
• Demonstrate data links UI from Windows® desktop
• Data links UI via RowsetViewer
• RowsetViewer is available in the
data access SDK
AGENDA
Review of OLE DB object model
New in OLE DB 2.0
Connecting to OLE DB data sources
➔Navigating hierarchical data
• OLE DB service components
• Questions and answers
NAVIGATING HIERARCHICAL
DATA
• Data is more than just isolated tables
• Hierarchies arrange data “nodes” in a tree
• Modeling hierarchies in OLE DB
OLE DB
IRowset->GetNextRows(chap1,…)
chap1
chap1
IRowset->GetNextRows(chap2,…)
chap2
chap2
IRowset->GetNextRows(chap3,…)
chap3
chap3
OLE DB
... ... ... ...
...
...
...
...
...
...
...
HIERARCHIES VIA CHAPTERS
• Efficiently expose hierarchical data through a single rowset
per level
• Appears as child recordsets in ADO 2.0
SHAPE EXAMPLE
SHAPE {select * from Orders}
APPEND({select * from `Order
Details`} RELATE OrderID TO
OrderID)
Orders rowset
OLE DB
...
...
OLE DB
... ... ... ...
Order details rowset
chap1
chap2
chap3
...
...
...
...
...
chap1
chap2
chap3
SHAPE PROVIDER
• Constructs hierarchical rowsets from data providers
• Driven by Shape data
manipulation syntax
◆ Types of Hierarchies
⚫ Appends chapter-valued columns to parent
rowset
⚫ Generates parent rowset from child rowset
with aggregations
⚫ Parameterised Hierarchies
SHAPE EXAMPLE
• Load shape provider’s data link
from storage
• Create a command object
• Set command text with a shape command
• Set any rowset properties
on the command
• Execute the command to obtain
parent rowset
// Create an instance of the OLE DB Initialization Component
hr = CoCreateInstance( CLSID_MSDAINITIALIZE, NULL,
CLSCTX_INPROC_SERVER, IID_IDataInitialize,
(void **)&pIDataInit);
if (FAILED(hr))
{ ...}
// Read the Data Link file for this example:
hr = pIDataInit->LoadStringFromStorage(pwszFileName,
&pwszInitString);
if (FAILED(hr))
{ ...}
// Create a Data Source object using the initialization string
hr = pIDataInit->GetDataSource(NULL, CLSCTX_INPROC_SERVER,
pwszInitString,IID_IDBInitialize, (IUnknown**) &pIDBInit);
if (FAILED(hr))
{ ...}
// Create the command object
hr = pSession->QueryInterface( IID_IDBCreateCommand,(void
**)&pIDBCreateCommand );
if (FAILED(hr))
{ ...}
hr = pIDBCreateCommand->CreateCommand( NULL,
IID_ICommandText, (IUnknown **)&pICommandText);
if (FAILED(hr))
{ ...}
pwsz_CommandText =
L"SHAPE{select * from Orders} COMPUTE (SUM(FREIGHT)) as
CHAPTER by customerID) ";
hr = pICommandText->SetCommandText( guidDialect,
pwsz_CommandText);
if (FAILED(hr))
{ ...}
NAVIGATING CHAPTERS
• IParentRowset::GetChildRowset
returns child rowset
• IRowset:GetNextRows(hChapter…) returns child rows for
that chapter
AGENDA
Review of OLE DB object model
New in OLE DB 2.0
Connecting to OLE DB data sources
Navigating hierarchical data
➔OLE DB service components
• Questions and answers
SERVICE COMPONENTS
• What are service components?
• How do they work?
• 2.0 service components
• Client cursor engine
• Resource pooling
• How do I use them?
Service Components make up the difference
Minimum provider interfaces
Service
components
OLE DB consumer
WHAT ARE
SERVICE COMPONENTS?
• A bridge between consumer expectation and provider
capability
WHAT ARE
SERVICE COMPONENTS?
• OLE DB core components that augment a provider’s
functionality
• Work with existing providers
• Without knowledge of the service
• Without special logic
• Work with consumers
• ADO uses them automatically
SERVICE COMPONENTS
• Service component
manager
• Invokes services
as needed
• Handles navigation
between interfaces
implemented by
different objects
• Provides a common
entry point for hooking
other services
• Consumer calls
methods directly
OLE DB rowset
Provider rowset
Service component manager
Service component
Service component
2.0 SERVICE COMPONENTS
• Client cursor engine
• Scrollable cursors
• IRowsetFind implementation
• Updateable rowsets over a SQL provider
◆ Resource pooling
⚫ Multiple, homogenous pools
⚫ Caches provider information
⚫ Automatic transaction enlistment in Microsoft
Transaction Server
USING SERVICE COMPONENTS
• Invoking service components
• Create a data source using IDataInitialize or
IDBPromptInitialize
• Use ADO
• Use the data links UI
• Service component manager determines which services to
invoke
• Applications should request the functionality they want
• Via command and rowset properties
DISABLING SERVICE
COMPONENTS
• By provider
• OLEDB_SERVICES registry entry
◆ By Consumer
⚫ Property control of core services
⚫ “OLE DB Services” String
CLIENT CURSOR EXAMPLE
• Connect to a sample provider
• Request backwards scrolling
• Re-connect using service components
• Demonstrate scrolling
OLE DB RESOURCE POOLING
• Improves performance and scaling
• Works with Microsoft Transaction Server
• What is pooled?
• Initialized data source object
Based on connection info
• Associated session object
• Provides multiple, homogenous pools
• Reduces contention
• Manages object lifetimes and
state changes
OLE DB POOLING
• Application
• Calls middle tier object
◆ OLE DB services
⚫ Returns proxy DSO
⚫ Sets initialization properties
⚫ Calls Initialize()
⚫ Caches information
⚫ Sets cached properties
⚫ Calls Initialize()
⚫ Creates a session
⚫ Enlists in transaction
⚫ Does work
Windows NT
MTS
◆ Middle tier object
⚫ Calls CreateDBInstance()
OLE DB services
OLE DB
⚫ Creates provider DSO
SQL Server
DSO
Provider
DCOM
MT
O
OLE DB POOLING
• Application
• Calls middle tier object
◆ Middle tier object
⚫ Calls CreateDBInstance()
◆ OLE DB services
⚫ Returns proxy DSO
⚫ Sets initialization properties
⚫ Calls Initialize()
⚫ Caches information
⚫ Creates Provider DSO
⚫ Sets cached properties
⚫ Calls Initialize()
⚫ Creates a Session
⚫ Enlists in transaction
⚫ Does work
⚫ Goes away
Windows NT
MTS
OLE DB services
OLE DB
SQL Server
DSO
Provider
OLE DB POOLING
Windows NT
MTS
OLE DB services
OLE DB
SQL Server
DSO
Provider
HTTP
Internet
Information
Server
MT
O
Web
browser
⚫ Calls middle tier object
⚫ Calls CreateDBInstance()
⚫ Returns proxy DSO
⚫ Sets initialization properties
⚫ Calls Initialize()
⚫ Caches information
⚫ Sets cached properties
⚫ Calls Initialize()
⚫ Creates a Session
⚫ Enlists in transaction
⚫ Does work
Provider
OLE DB
DSO
Oracle
◆ Creates provider DSO
◆ Middle tier object
◆ OLE DB Services
◆ Web browser
OLE DB POOLING
Windows NT
MTS
OLE DB services
OLE DB
SQL Server
DSO
Provider
Web
browser
⚫ Calls middle tier object
⚫ Calls CreateDBInstance()
⚫ Returns proxy DSO
⚫ Sets initialization properties
⚫ Calls Initialize()
⚫ Caches information
⚫ Sets cached properties
⚫ Calls Initialize()
⚫ Creates a Session
⚫ Enlists in transaction
⚫ Does work
⚫ Goes away
Provider
OLE DB
DSO
Oracle
◆ Creates provider DSO
◆ Middle tier object
◆ OLE DB Services
◆ Web browser
OLE DB POOLING
Windows NT
MTS
OLE DB services
OLE DB
SQL Server
Provider
DSO
Web
browser
Provider
DSO
Oracle
DCOM
MT
O
◆ Application
⚫ Calls middle tier object
◆ OLE DB Services
⚫ Sets initialization properties
⚫ Calls CreateDBInstance()
⚫ Caches information
⚫ Does work
◆ Middle tier object
⚫ Returns proxy DSO
⚫ Returns DSO from pool DSO
⚫ Calls
Initialize()
OLE DB POOLING
Windows NT
MTS
OLE DB services
OLE DB
SQL Server
Provider
DSO
Web
browser
Provider
DSO
Oracle
◆ Application
⚫ Calls middle tier object
◆ Middle tier object
⚫ Calls CreateDBInstance()
⚫ Sets initialization properties
⚫ Calls Initialize()
⚫ Does work
⚫ Goes away
◆ OLE DB services
⚫ Returns proxy DSO
⚫ Caches information
⚫ Returns DSO from pool
Windows NT
MTS
OLE DB services
OLE DB
SQL Server
Provider
DSO
Web
browser
Provider
DSO
Oracle
◆ Application
◆ Middle tier object
◆ OLE DB services
OLE DB POOLING
OLE DB POOLING
OLE DB Services
MTS
Web
browser
Windows NT
OLE DB
DSO
SQL
Server
Provider
◆ Application
◆ Middle tier object
◆ OLE DB services
⚫ Oracle connection times out
OLE DB POOLING
OLE DB Services
MTS
Web
browser
Windows NT
◆ Application
◆ Middle tier object
◆ OLE DB services
⚫ Oracle connection times out
⚫ SQL Server connection
times out
LEVERAGING OLE DB POOLING
• Connect using CreateDBInstance, GetDataSource, or data
links UI
• Don’t request provider specific interfaces prior to
connecting
• Don’t request prompting
• Don’t uninitialize
• Only use one session per connection
• …or, just use ADO!
OLE DB SUMMARY
• OLE DB 2.0 improves the architecture for universal data
access
• Easier access to your data sources
• Ability to model hierarchical data
• Service components
• OLE DB 2.0 service components
• Client cursor engine support for scrolling and searching
• Resource pooling improves performance and scalability
• Leveraging service components is easy

More Related Content

PDF
OLE DB Provider Development - Encapsulating a Service Provider
PPS
VISUAL BASIC .net data accesss vii
PPTX
ADO.NET -database connection
PPT
Marmagna desai
PPTX
76.pptx ajx ppt file for univercity of granted
PPT
Chapter 4 event it theory programming.pptx
PDF
Presentation on the ADO.NET framework in C#
PPT
OLE DB Provider Development - Encapsulating a Service Provider
VISUAL BASIC .net data accesss vii
ADO.NET -database connection
Marmagna desai
76.pptx ajx ppt file for univercity of granted
Chapter 4 event it theory programming.pptx
Presentation on the ADO.NET framework in C#

Similar to OLE DB 2.0 Architecture - Supporting Remote Data Exchange (20)

PPTX
Ado .net
PPTX
Sql server engine cpu cache as the new ram
PPT
Ado.net
PPT
PPT
vishual basic data base Pankaj
PPT
Introduction to ADO.NET
PPTX
Connected data classes
PPT
Introduction to ado
PDF
5c8605.ado.net
PPT
ASP.NET Session 11 12
PPTX
Datasource in asp.net
DOCX
Ado dot net complete meterial (1)
PDF
An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...
PDF
IBM DB2 App Development with Microsoft Visual C#
PPTX
LECTURE 14 Data Access.pptx
PPT
B01DataMgt.ppt
PPT
Introduction to Data Management Powerpoint
PPT
Introduction to ado.net
PPT
ملخص تقنية تصميم صفحات الويب - الوحدة السادسة
PPT
ملخص تقنية تصميم صفحات الويب - الوحدة السادسة
Ado .net
Sql server engine cpu cache as the new ram
Ado.net
vishual basic data base Pankaj
Introduction to ADO.NET
Connected data classes
Introduction to ado
5c8605.ado.net
ASP.NET Session 11 12
Datasource in asp.net
Ado dot net complete meterial (1)
An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...
IBM DB2 App Development with Microsoft Visual C#
LECTURE 14 Data Access.pptx
B01DataMgt.ppt
Introduction to Data Management Powerpoint
Introduction to ado.net
ملخص تقنية تصميم صفحات الويب - الوحدة السادسة
ملخص تقنية تصميم صفحات الويب - الوحدة السادسة
Ad

More from Arun Seetharaman (13)

PDF
Implementing Load Balancing in COM+ Applications
PDF
Advanced Windows DNA Scripting with Visual InterDev
PDF
Implementing DHTML Behavior Script Components
PDF
Creating Data-based Applications Using DHTML
PDF
COM Events for Late-bound Delivery of Information
PDF
Understanding Windows NT Internals - Part 4
PDF
Understanding Windows NT Internals - Part 5
PDF
Understanding Windows NT Internals - Part 3
PDF
Understanding Windows NT Internals - Part 1
PDF
Understanding Windows NT Internals - Part 2
PDF
Data Structures in Java and Introduction to Collection Framework
PDF
AWT Enhancements in V1.1 - Supporting Richer GUI Development
PDF
Java Foundation Classes - Building Portable GUIs
Implementing Load Balancing in COM+ Applications
Advanced Windows DNA Scripting with Visual InterDev
Implementing DHTML Behavior Script Components
Creating Data-based Applications Using DHTML
COM Events for Late-bound Delivery of Information
Understanding Windows NT Internals - Part 4
Understanding Windows NT Internals - Part 5
Understanding Windows NT Internals - Part 3
Understanding Windows NT Internals - Part 1
Understanding Windows NT Internals - Part 2
Data Structures in Java and Introduction to Collection Framework
AWT Enhancements in V1.1 - Supporting Richer GUI Development
Java Foundation Classes - Building Portable GUIs
Ad

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
Teaching material agriculture food technology
PPTX
sap open course for s4hana steps from ECC to s4
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
Encapsulation_ Review paper, used for researhc scholars
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Review of recent advances in non-invasive hemoglobin estimation
Agricultural_Statistics_at_a_Glance_2022_0.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
cuic standard and advanced reporting.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MYSQL Presentation for SQL database connectivity
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Teaching material agriculture food technology
sap open course for s4hana steps from ECC to s4
The AUB Centre for AI in Media Proposal.docx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Chapter 3 Spatial Domain Image Processing.pdf
A comparative analysis of optical character recognition models for extracting...

OLE DB 2.0 Architecture - Supporting Remote Data Exchange

  • 1. OLE DB 2.0 ARCHITECTURE Arun Seetharaman Computer Call January 20, 1999
  • 4. AGENDA ➔Review of OLE DB object model • New in OLE DB 2.0 • Connecting to OLE DB data sources • Navigating hierarchical data • OLE DB service components • Questions and answers
  • 5. DATA AS A COMMON ABSTRACTION • Common representation of data • Code/knowledge reuse • Tools can access data generically • Generic components can add functionality • Components can combine different types of data ◆ Sharing data ⚫ Reduces memory footprint ⚫ Reduces data movement ⚫ Better component coordination
  • 6. TERMINOLOGIES • Data Provider • Software that implements OLEDB Interfaces • Exposes data in a tabular form ◆ Consumer ⚫ Consumes the data ◆ Service Provider ⚫ Consumes data exposed by Data Provider ⚫ Transforms and provides data
  • 7. OLE DB DESIGN PHILOSOPHY • Data stores provide interfaces to native functionality • Data store is not required to implement extended functionality ◆ Consumers assume common functionality ⚫ Consumers don't need excess conditional code ◆ “Service components” augment data store's native functionality ⚫ Generic, reusable components provide a guaranteed level of interoperability
  • 8. Data source IDBCreateSession Rowset OpenRowset() Rowset Execute() OLE DB OBJECT MODEL ICommand Command CreateCommand() IDBCreateCommand IOpenRowset Session CreateSession()
  • 9. AGENDA Review of OLE DB object model ➔New in OLE DB 2.0 ➔Connecting to OLE DB data sources • Navigating hierarchical data • OLE DB service components • Questions and answers
  • 10. CONNECTING TO A DATA SOURCE BEFORE 2.0 • Via root enumerator • Passing provider’s CLSID to CoCreateInstance • Hard-code provider CLSIDs • Obtain CLSID via application specific code ◆ Disadvantages: ⚫ No common UI ⚫ No common way to represent or persist connection information
  • 11. CONNECTING TO A DATA SOURCE OLE DB 2.0 • OLE DB 2.0 provides common services to connect to data sources: • IDataInitialize • Persists connection strings • Leverages OLE DB services (More on this later…) • IDBPromptInitialize • Uses the data links UI • Manages data source properties and data link (*.UDL) files
  • 12. WHAT CAN I DO WITH IDATAINITIALIZE ? • Modify sample consumer to use IDataInitialize • Instantiate the OLE DB initialization service CLSID_MSDAINITIALIZE One simple change to current code • Create a Data Source object via IDataInitialize::CreateDBInstance
  • 13. // Create the Initialization Component hr = CoCreateInstance( CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, IID_IDataInitialize, (void **)&pIDataInit); if (FAILED(hr)) {… } // Create an instance of the OLE DB provider for Jet hr = pIDataInit->CreateDBInstance( CLSID_JETOLEDB_3_51, NULL, CLSCTX_INPROC_SERVER, NULL, IID_IDBInitialize, (IUnknown**) &pIDBInit); if (FAILED(hr)) {… }
  • 14. WHAT ELSE CAN I DO WITH IDATAINITIALIZE? • Given a data source, retrieve a connection string • GetInitializationString • Persist a connection string • WriteStringToStorage
  • 15. // Use IDataInitialize::GetInitializationString to return connection string hr = pIDataInit->GetInitializationString( (IUnknown*)pIDBInit, TRUE, &pwszInitString); if (FAILED(hr)) {… } // Use IDataInitialize::WriteStringToStorage to persist connection string hr = pIDataInit->WriteStringToStorage(pwszFileName, pwszInitString, CREATE_ALWAYS); if (FAILED(hr)) {… }
  • 16. WHAT ELSE CAN I DO WITH IDATAINITIALIZE? • Persist a connection string • LoadStringFromStorage • Given a connection string, instantiate a data source object • GetDataSource
  • 17. //Create the Initialization Component hr = CoCreateInstance( CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, IID_IDataInitialize, (void **)&pIDataInit); if (FAILED(hr)) {… } // Read the initialization info from previous example hr = pIDataInit->LoadStringFromStorage(pwszFileName, &pwszInitString); if (FAILED(hr)) {… } // Create a Data Source object using the initialization string hr = pIDataInit->GetDataSource(NULL, CLSCTX_INPROC_SERVER, pwszInitString,IID_IDBInitialize, (IUnknown**) &pIDBInit); if (FAILED(hr)) {… }
  • 18. DATA LINKS • Common UI for data sources • Can be used by any application • Reflects properties of the provider • Connection information can be persisted as “Data links” Data links can be used from ADO or OLE DB Invoked from desktop
  • 19. IDBPROMPTINITIALIZE • Program access to the Data Links service • PromptDataSource • Opens data link properties dialog • Returns a data link with properties • PromptFileName • Opens Select data link dialog • Returns path to data link (*.UDL) file
  • 20. DATA LINKS EXAMPLE • Demonstrate data links UI from Windows® desktop • Data links UI via RowsetViewer • RowsetViewer is available in the data access SDK
  • 21. AGENDA Review of OLE DB object model New in OLE DB 2.0 Connecting to OLE DB data sources ➔Navigating hierarchical data • OLE DB service components • Questions and answers
  • 22. NAVIGATING HIERARCHICAL DATA • Data is more than just isolated tables • Hierarchies arrange data “nodes” in a tree • Modeling hierarchies in OLE DB
  • 23. OLE DB IRowset->GetNextRows(chap1,…) chap1 chap1 IRowset->GetNextRows(chap2,…) chap2 chap2 IRowset->GetNextRows(chap3,…) chap3 chap3 OLE DB ... ... ... ... ... ... ... ... ... ... ... HIERARCHIES VIA CHAPTERS • Efficiently expose hierarchical data through a single rowset per level • Appears as child recordsets in ADO 2.0
  • 24. SHAPE EXAMPLE SHAPE {select * from Orders} APPEND({select * from `Order Details`} RELATE OrderID TO OrderID) Orders rowset OLE DB ... ... OLE DB ... ... ... ... Order details rowset chap1 chap2 chap3 ... ... ... ... ... chap1 chap2 chap3
  • 25. SHAPE PROVIDER • Constructs hierarchical rowsets from data providers • Driven by Shape data manipulation syntax ◆ Types of Hierarchies ⚫ Appends chapter-valued columns to parent rowset ⚫ Generates parent rowset from child rowset with aggregations ⚫ Parameterised Hierarchies
  • 26. SHAPE EXAMPLE • Load shape provider’s data link from storage • Create a command object • Set command text with a shape command • Set any rowset properties on the command • Execute the command to obtain parent rowset
  • 27. // Create an instance of the OLE DB Initialization Component hr = CoCreateInstance( CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, IID_IDataInitialize, (void **)&pIDataInit); if (FAILED(hr)) { ...} // Read the Data Link file for this example: hr = pIDataInit->LoadStringFromStorage(pwszFileName, &pwszInitString); if (FAILED(hr)) { ...} // Create a Data Source object using the initialization string hr = pIDataInit->GetDataSource(NULL, CLSCTX_INPROC_SERVER, pwszInitString,IID_IDBInitialize, (IUnknown**) &pIDBInit); if (FAILED(hr)) { ...}
  • 28. // Create the command object hr = pSession->QueryInterface( IID_IDBCreateCommand,(void **)&pIDBCreateCommand ); if (FAILED(hr)) { ...} hr = pIDBCreateCommand->CreateCommand( NULL, IID_ICommandText, (IUnknown **)&pICommandText); if (FAILED(hr)) { ...} pwsz_CommandText = L"SHAPE{select * from Orders} COMPUTE (SUM(FREIGHT)) as CHAPTER by customerID) "; hr = pICommandText->SetCommandText( guidDialect, pwsz_CommandText); if (FAILED(hr)) { ...}
  • 29. NAVIGATING CHAPTERS • IParentRowset::GetChildRowset returns child rowset • IRowset:GetNextRows(hChapter…) returns child rows for that chapter
  • 30. AGENDA Review of OLE DB object model New in OLE DB 2.0 Connecting to OLE DB data sources Navigating hierarchical data ➔OLE DB service components • Questions and answers
  • 31. SERVICE COMPONENTS • What are service components? • How do they work? • 2.0 service components • Client cursor engine • Resource pooling • How do I use them?
  • 32. Service Components make up the difference Minimum provider interfaces Service components OLE DB consumer WHAT ARE SERVICE COMPONENTS? • A bridge between consumer expectation and provider capability
  • 33. WHAT ARE SERVICE COMPONENTS? • OLE DB core components that augment a provider’s functionality • Work with existing providers • Without knowledge of the service • Without special logic • Work with consumers • ADO uses them automatically
  • 34. SERVICE COMPONENTS • Service component manager • Invokes services as needed • Handles navigation between interfaces implemented by different objects • Provides a common entry point for hooking other services • Consumer calls methods directly OLE DB rowset Provider rowset Service component manager Service component Service component
  • 35. 2.0 SERVICE COMPONENTS • Client cursor engine • Scrollable cursors • IRowsetFind implementation • Updateable rowsets over a SQL provider ◆ Resource pooling ⚫ Multiple, homogenous pools ⚫ Caches provider information ⚫ Automatic transaction enlistment in Microsoft Transaction Server
  • 36. USING SERVICE COMPONENTS • Invoking service components • Create a data source using IDataInitialize or IDBPromptInitialize • Use ADO • Use the data links UI • Service component manager determines which services to invoke • Applications should request the functionality they want • Via command and rowset properties
  • 37. DISABLING SERVICE COMPONENTS • By provider • OLEDB_SERVICES registry entry ◆ By Consumer ⚫ Property control of core services ⚫ “OLE DB Services” String
  • 38. CLIENT CURSOR EXAMPLE • Connect to a sample provider • Request backwards scrolling • Re-connect using service components • Demonstrate scrolling
  • 39. OLE DB RESOURCE POOLING • Improves performance and scaling • Works with Microsoft Transaction Server • What is pooled? • Initialized data source object Based on connection info • Associated session object • Provides multiple, homogenous pools • Reduces contention • Manages object lifetimes and state changes
  • 40. OLE DB POOLING • Application • Calls middle tier object ◆ OLE DB services ⚫ Returns proxy DSO ⚫ Sets initialization properties ⚫ Calls Initialize() ⚫ Caches information ⚫ Sets cached properties ⚫ Calls Initialize() ⚫ Creates a session ⚫ Enlists in transaction ⚫ Does work Windows NT MTS ◆ Middle tier object ⚫ Calls CreateDBInstance() OLE DB services OLE DB ⚫ Creates provider DSO SQL Server DSO Provider DCOM MT O
  • 41. OLE DB POOLING • Application • Calls middle tier object ◆ Middle tier object ⚫ Calls CreateDBInstance() ◆ OLE DB services ⚫ Returns proxy DSO ⚫ Sets initialization properties ⚫ Calls Initialize() ⚫ Caches information ⚫ Creates Provider DSO ⚫ Sets cached properties ⚫ Calls Initialize() ⚫ Creates a Session ⚫ Enlists in transaction ⚫ Does work ⚫ Goes away Windows NT MTS OLE DB services OLE DB SQL Server DSO Provider
  • 42. OLE DB POOLING Windows NT MTS OLE DB services OLE DB SQL Server DSO Provider HTTP Internet Information Server MT O Web browser ⚫ Calls middle tier object ⚫ Calls CreateDBInstance() ⚫ Returns proxy DSO ⚫ Sets initialization properties ⚫ Calls Initialize() ⚫ Caches information ⚫ Sets cached properties ⚫ Calls Initialize() ⚫ Creates a Session ⚫ Enlists in transaction ⚫ Does work Provider OLE DB DSO Oracle ◆ Creates provider DSO ◆ Middle tier object ◆ OLE DB Services ◆ Web browser
  • 43. OLE DB POOLING Windows NT MTS OLE DB services OLE DB SQL Server DSO Provider Web browser ⚫ Calls middle tier object ⚫ Calls CreateDBInstance() ⚫ Returns proxy DSO ⚫ Sets initialization properties ⚫ Calls Initialize() ⚫ Caches information ⚫ Sets cached properties ⚫ Calls Initialize() ⚫ Creates a Session ⚫ Enlists in transaction ⚫ Does work ⚫ Goes away Provider OLE DB DSO Oracle ◆ Creates provider DSO ◆ Middle tier object ◆ OLE DB Services ◆ Web browser
  • 44. OLE DB POOLING Windows NT MTS OLE DB services OLE DB SQL Server Provider DSO Web browser Provider DSO Oracle DCOM MT O ◆ Application ⚫ Calls middle tier object ◆ OLE DB Services ⚫ Sets initialization properties ⚫ Calls CreateDBInstance() ⚫ Caches information ⚫ Does work ◆ Middle tier object ⚫ Returns proxy DSO ⚫ Returns DSO from pool DSO ⚫ Calls Initialize()
  • 45. OLE DB POOLING Windows NT MTS OLE DB services OLE DB SQL Server Provider DSO Web browser Provider DSO Oracle ◆ Application ⚫ Calls middle tier object ◆ Middle tier object ⚫ Calls CreateDBInstance() ⚫ Sets initialization properties ⚫ Calls Initialize() ⚫ Does work ⚫ Goes away ◆ OLE DB services ⚫ Returns proxy DSO ⚫ Caches information ⚫ Returns DSO from pool
  • 46. Windows NT MTS OLE DB services OLE DB SQL Server Provider DSO Web browser Provider DSO Oracle ◆ Application ◆ Middle tier object ◆ OLE DB services OLE DB POOLING
  • 47. OLE DB POOLING OLE DB Services MTS Web browser Windows NT OLE DB DSO SQL Server Provider ◆ Application ◆ Middle tier object ◆ OLE DB services ⚫ Oracle connection times out
  • 48. OLE DB POOLING OLE DB Services MTS Web browser Windows NT ◆ Application ◆ Middle tier object ◆ OLE DB services ⚫ Oracle connection times out ⚫ SQL Server connection times out
  • 49. LEVERAGING OLE DB POOLING • Connect using CreateDBInstance, GetDataSource, or data links UI • Don’t request provider specific interfaces prior to connecting • Don’t request prompting • Don’t uninitialize • Only use one session per connection • …or, just use ADO!
  • 50. OLE DB SUMMARY • OLE DB 2.0 improves the architecture for universal data access • Easier access to your data sources • Ability to model hierarchical data • Service components • OLE DB 2.0 service components • Client cursor engine support for scrolling and searching • Resource pooling improves performance and scalability • Leveraging service components is easy