OLE DB Provider Development - Encapsulating a Service Provider
arunsnarayanan
4 views
30 slides
Mar 11, 2025
Slide 1 of 30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
About This Presentation
"OLE DB provider development" refers to the process of creating a software component, called an OLE DB provider, which enables applications to access data from a specific data source by implementing the OLE DB standard interfaces
Size: 813.84 KB
Language: en
Added: Mar 11, 2025
Slides: 30 pages
Slide Content
OLE DB PROVIDER
DEVELOPMENT
Arun Seetharaman
Computer Call
January 20, 1999
AGENDA
•Universal Data Access
•What is an OLE DB provider?
•Creating an OLE DB provider with the OLE DB Provider
Templates
•Extending the provider
•Questions and answers
Data
access
Universal Data Access
WHAT IS AN OLE DB
DATA PROVIDER?
•Implements core OLE DB interfaces
•Common interfaces to native functionality
•Does not require data to look like a relational
database
•Implements extended OLE DB interfaces to
expose native extended functionality
SCENARIOS
•Relational Data
•ODBC Driver exists, No OLE DB Provider
•You App uses ADO to talk to OLE DB Provider for ODBC ,
which talks to the ODBC driver
◆Relational Data
⚫OLE DB Provider exists
⚫You App uses ADO to talk to OLE DB Provider
SCENARIOS
•Data in Exchange Server
•OLE DB Provider exists, No Query Engine
•You App uses ADO to talk to MS Exchange OLE DB Provider,
calls upon a Query Processor component to handle querying
◆Data in NT File System
⚫OLE DB Provider over Microsoft Index Server
⚫You App uses ADO to talk to OLE DB Provider
WHY WRITE A PROVIDER?
•To participate in Universal Data Access:
⚫Take advantage of ADO to provide C/C++,
Java, Visual Basic
®
, IIS and OLE
Automation programmers easy access to
your data
⚫Expose your data to SQL Server, Access,
Excel, and third-party consumers
⚫Add power to your data through common
Query Processor, Cursor, Notification, and
Remoting components
⚫Participate in heterogeneous joins
PROVIDER TEMPLATE SUPPORT
•You could implement a bunch
of interfaces
•OLE DB Provider Templates
•Implements 20 of the most common OLE DB interfaces
•New option in ATL Object Wizard
•Minimal providers ready to go
in ten minutes
PROVIDER TEMPLATE SUPPORT
•Implements data source, session, command, and rowset
objects
•Implements all mandatory interfaces
•Minimal case:
•Developer changes PROVIDER_COLUMN_MAP and Execute()
•Significant case:
•Developer adds in additional objects
and interfaces
CreateSession()
Session
IDBCreateCommand
IOpenRowset
Execute()
Rowset
Rowset
OpenRowset()
Command
ICommand
CreateCommand()
OLE DB PROVIDER STRUCTURE
Data Source
IDBCreateSession
PROPERTIES
•Can be set Objectwise
•Defines Object specific behaviour
•Type, Value, Read/Write attribute
•Property Sets
•Properties with the same GUID
•Many are Pre-defined in OLEDB
•Provider can define custom properties
GUID : PropertySet A
Count: 3
Pointer :
DBPROPSET Array
ID: Property 1
Value : Value1
ID: Property 2
Value : Value2
ID: Property 1
Value : Value1
GUID : PropertySet A
Count: 3
Pointer :
DBPROPIDSET Array
Property 1
Property 2
Property 3
DBPROPID Arrays
DATA SOURCE INTERFACES
•IDBProperties
•Sets properties used in initialization
•Returns information about
provider's capabilities
•Data Source Properties
Data Source Name, Version, Threading Model
•Initialization Properties
User ID, Password, Locale ID, Timeout
DATA SOURCE INTERFACES
•IDBInitialize
•Connects to the provider
•State Change to ‘Initialized’
◆ IDBCreateSession
⚫Gets a session object
◆ IPersist
⚫Returns your CLSID
⚫To persist Connection Information
SESSION INTERFACES
•IGetDataSource
•Returns parent datasource
•ISessionProperties
•Sets properties on session
Transaction Isolation Levels Supported in Auto-Commit Mode
SESSION INTERFACES
•IOpenRowset
•To Work directly with Table
•No overhead of Query Language support
◆IDBCreateCommand (Optional)
⚫Only if you support commands
COMMAND INTERFACES
•ICommandProperties
•Set properties for open rowset
◆ ICommandText
⚫ Set and execute command
COMMAND INTERFACES
•IAccessor
•Defines how parameters are read
•Binds each column or parameter to Consumer’s buffer
◆IColumnsInfo
⚫Provides metadata about Columns
ROWSET OBJECT
People
Name Address Papers Picture Voice
David
Mike
Monica
NY
CA
DC
...
IStream
IRowset
IDraw IPlay
ROWSET OBJECT
•Universal abstraction for tabular data
•Base data, query results,
computed data, schema…
◆ Rows can contain COM objects
◆Efficient, streamlined access to large objects
ROWSET OBJECT
•Rowset data can be shared
⚫Multiple Consumers
⚫Multiple Components
⚫Notifications
⚫Deferred/Immediate Updates
ROWSET INTERFACES
•IColumnsInfo
•Describes the columns of the rowset
◆IAccessor
⚫Defines how consumer reads data
◆ IRowsetInfo
⚫Returns rowset properties
Updatability, Bookmarks ...
⚫Interface Support
Find, Conversions ...
ROWSET INTERFACES
•IRowset
•GetNextRows retrieves row handles
•GetData reads data from row handles
◆ IConvertType
⚫Use the Data Conversion library
CREATING AN OLE DB PROVIDER
•Run the OLE DB Provider Wizard
•Generates COM objects for data source, session,
command, and rowset
•Modify and extend code
class CAgentMan
{
public:
TCHAR szCommand[256];
TCHAR szText[256];
BEGIN_PROVIDER_COLUMN_MAP(CAgentMan)
PROVIDER_COLUMN_ENTRY(“Field1”, 1, szCommand)
PROVIDER_COLUMN_ENTRY(“Field2”, 2, szText)
END_PROVIDER_COLUMN_MAP()
};
MODIFY DATA STRUCTURE
•Represents one row of data
•Contains data members and meta -data
HRESULT Execute(DBPARAMS * pParams, LONG* pcRowsAffected)
{
...
}
MODIFY EXECUTE IN ROWSET
•Command is stored in m_strCommandText
•Create instances of your
data structure
•Place instances in m_rgRowData
•Set pcRowsAffected
DEMO
•Creating a minimal provider
•Run Provider Wizard
•Modify data structure
•Modify PROVIDER_COLUMN_MAP
•Modify Execute()
EXTENDING THE PROVIDER
•Schema rowsets
•Properties
•Add in validation routines
•Add additional OLE DB interfaces
CONFORMANCE TESTS
•Generic OLE DB tests that:
•Verify conformance to minimum level
•Test correctness of exposed interfaces
•Based on sample test suites
in OLE DB SDK
•Provide a performance benchmark
•Include ADO acceptance tests
SUMMARY
•Writing a provider gives you…
•C/C++, OLE Automation, Java,
and scripting access to your data through ADO
•Exposure to Microsoft
®
and third-party tools, products, and
components