Click here to Skip to main content
15,881,882 members
Articles / Desktop Programming / MFC

Exposing tabular data from your COM object - Part 2

Rate me:
Please Sign up or sign in to vote.
5.00/5 (7 votes)
28 Jul 2000CPOL 94.9K   1.1K   33  
The ATL OLE DB Provider templates appear to rely on the fact that your data is kept in a simple array, but that's not really the case at all!
// SimpleDataObject.idl : IDL source for SimpleDataObject.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (SimpleDataObject.tlb) and marshalling code.

import "oaidl.idl";
import "ocidl.idl";
import "IGetAsADORecordset.idl";
import "IGetAsOLEDBRowset.idl";		

	[
		object,
		uuid(528F2F71-62A0-11D3-8277-0020186676FB),
	
		helpstring("IMyDataObject Interface"),
		pointer_default(unique)
	]
	interface IMyDataObject : IUnknown
	{
		HRESULT SetColumnSize(
			[in] long columnSize);

		HRESULT AddColumn(
			[in] BSTR columnName, 
			[out, retval] long *index);
		
		HRESULT GetColumnName(
			[in] long index,
			[out, retval] BSTR *columnName);

		HRESULT AddRow(
			[out, retval] long *index);
		
		HRESULT RemoveRow(
			[in] long index);
		
		HRESULT Depth(
			[out, retval] long *depth);

		HRESULT Width(
			[out, retval] long *width);

		HRESULT SetAt(
			[in] long rowIndex, 
			[in] long columnIndex, 
			[in] BSTR value);

		HRESULT GetAt(
			[in] long rowIndex, 
			[in] long columnIndex, 
			[out, retval] BSTR *value);
	};


[
	uuid(528F2F63-62A0-11D3-8277-0020186676FB),
	version(1.0),
	helpstring("SimpleDataObject 1.0 Type Library")
]
library SIMPLEDATAOBJECTLib
{
	importlib("stdole32.tlb");
	importlib("stdole2.tlb");

	[
		uuid(528F2F72-62A0-11D3-8277-0020186676FB),
		helpstring("MyDataObject Class")
	]
	coclass MyDataObject
	{
		[default] interface IMyDataObject;
		interface IGetAsADORecordset;
		interface _Recordset;
		interface _IGetAsOLEDBRowset;
	};
	[
		uuid(29B85006-649A-11D3-827D-0020186676FB),
		helpstring("ConversionProvider OLE DB Provider")
	]
	coclass ConversionProvider
	{
		interface IUnknown;
	};
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) JetByte Limited
United Kingdom United Kingdom
Len has been programming for over 30 years, having first started with a Sinclair ZX-80. Now he runs his own consulting company, JetByte Limited and has a technical blog here.

JetByte provides contract programming and consultancy services. We can provide experience in COM, Corba, C++, Windows NT and UNIX. Our speciality is the design and implementation of systems but we are happy to work with you throughout the entire project life-cycle. We are happy to quote for fixed price work, or, if required, can work for an hourly rate.

We are based in London, England, but, thanks to the Internet, we can work 'virtually' anywhere...

Please note that many of the articles here may have updated code available on Len's blog and that the IOCP socket server framework is also available in a licensed, much improved and fully supported version, see here for details.

Comments and Discussions