"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
2. 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
4. 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
5. 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
6. 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
7. 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
8. 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
9. 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
11. 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
12. 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
13. 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
14. 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
16. SESSION INTERFACES
• IOpenRowset
• To Work directly with Table
• No overhead of Query Language support
◆ IDBCreateCommand (Optional)
⚫ Only if you support commands
18. COMMAND INTERFACES
• IAccessor
• Defines how parameters are read
• Binds each column or parameter to Consumer’s buffer
◆ IColumnsInfo
⚫ Provides metadata about Columns
20. 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
21. ROWSET OBJECT
• Rowset data can be shared
⚫ Multiple Consumers
⚫ Multiple Components
⚫ Notifications
⚫ Deferred/Immediate Updates
22. 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 ...
23. ROWSET INTERFACES
• IRowset
• GetNextRows retrieves row handles
• GetData reads data from row handles
◆ IConvertType
⚫ Use the Data Conversion library
24. 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
25. 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
26. 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
27. DEMO
• Creating a minimal provider
• Run Provider Wizard
• Modify data structure
• Modify PROVIDER_COLUMN_MAP
• Modify Execute()
28. EXTENDING THE PROVIDER
• Schema rowsets
• Properties
• Add in validation routines
• Add additional OLE DB interfaces
29. 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
30. 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