registering an Ole Db provider

D

Duncan Winn

I have written an Ole Db provider. It seems to be registered in the
Operating system to a degree, but not fully, i.e. I can access it from a
client that I have written. But it does not appear in Database Explorer's
list of viable Ole Db drivers...

Any suggestions??
 
R

rlfine

Duncan,

When you register your provider, make sure that you have an entry in
the registry under the CLSID with Key Name of OLE DB PROVIDER. The
Database Explorer and other tools scan HKEY_CLASSES_ROOT\CLSID looking
for all entries that have a key with the above name. For examples, have
a look in the registry at the CLSIDs for MSDAORA and SqlServer.

regards
roy fine
 
D

Duncan Winn

Thanks Roy,
make sure that you have an entry in the registry under the
CLSID with Key Name of OLE DB PROVIDER

Are you talking about the rgs file????
Do you know if Excel (2000) can talk to Ole Db providers ?

Thanks,

Duncan.
 
R

Roy Fine

Duncan Winn said:
Thanks Roy,
Not specifically -- sounds as if you have used the ATL Provider
templates to develop your OLEDB Provider - I have looked at the ATL
approach a couple of times, but for the OLEDB provider that I developed,
I did not use the templates, rather did it in straight COM. If you can
edit the resource that creates the rgs file, then that would be the
place to do it. But first, I would have a look in the registry and see
if the OLE DB PROVIDER key is present, and that it has a value that
describes your provider. If that key is not present, I would be a
trivial matter to add the key by hand and test to see if that resolved
the problem. If the problem is fixed with the adding of the key, then
we go back a couple of steps and try to find the best place to implement
the fix...
Are you talking about the rgs file????
Do you know if Excel (2000) can talk to Ole Db providers ?

Yes it can. Try this:
---------------------------------------
1. Create a UDL file somewhere - I like the desktop for quick and easy
tests.
2. Open the UDL, and select a Provider and the DataSource - I like Jet
4.0 for testing purposes.
3. Test the connection just to make sure it works.
4. Close the UDL
5. Start MSFT Excel - in File|Open, select "All Data Sources (*.udl
....)" for the file type and navigate to the desktop, and select the UDL
created in step 1.
6. Select the Open button, and then select a table from the list
displayed.


I hope this helps...

regards
roy fine
 
D

Duncan Winn

Roy,

thanks for the help....
sounds as if you have used the ATL Provider
templates to develop your OLEDB Provider

Yep that's correct. I am brand new to providers and I was thrown in the deep
end so I thought that was the best place to start.
make sure that you have an entry in the registry under the
CLSID with Key Name of OLE DB PROVIDER

I have looked in the registry editor and I have found the following .. e.g.

HKEY_CLASSES_ROOT (this is a folder)
CDFAP.CDFap (this is a folder)
CLSID (this is a folder)
Name (Default) Type REG_SZ Data {A6D8083D-8B.... etc}
CDFAP.CDFap.1 (this is a folder)
CLSID (this is a folder)
Name (Default) Type REG_SZ Data {A6D8083D-8B.... etc}

So does this mean that I need to change the Default to OLE DB PROVIDER, or
are you talking about something entirly different? The provides is
available in the list from the UDL step 2 you talked me through........
2. Open the UDL, and select a Provider and the DataSource

So maybe this side of things is OK???
6. Select the Open button, and then select a table from the list
displayed.

No tables are displayed when I select my provider only the following gets
imbedded in my spread sheet:

[oledb]
; Everything after this line is an OLE DB initstring
Provider=CCDFapSource Object;Persist Security Info=False;User
ID="";Data Source=cdf_db;Location=D:\fums\cdf_db;Mode=Read;Extended
Properties=""

Any suggestions???
I hope this helps...

Yes it does, I have found very few people available to advise me about
providers, your help over the past few months (you have responded to alot of
my messages) has been a real God send.

Thanks,
Duncan.
 
R

Roy Fine

Duncan,

I have looked in the registry editor and I have found the following .. e.g.

HKEY_CLASSES_ROOT (this is a folder)
CDFAP.CDFap (this is a folder)
CLSID (this is a folder)
Name (Default) Type REG_SZ Data {A6D8083D-8B.... etc}
CDFAP.CDFap.1 (this is a folder)
CLSID (this is a folder)
Name (Default) Type REG_SZ Data {A6D8083D-8B.... etc}

Wrong place -- that's the ProgID - it is the posh, human friendly name -
we are looking for the nasty computer readable name - the CLSID. Here
is a snip from the registry for the Microsoft SqlServer OLEDB Provider:

/* ************************************ */
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}]
@="SQLOLEDB"
"OLEDB_SERVICES"=dword:ffffffff

[HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}\Extended
Errors]
@="Extended Error Service"

[HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}\Extended
Errors\{C0932C62-38E5-11d0-97AB-00C04FC2AD98}]
@="SQLOLEDB Error Lookup"

[HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}\Implemen
ted Categories]

[HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}\Implemen
ted Categories\{D267E19A-0B97-11D2-BB1C-00C04FC9B532}]

[HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}\InprocSe
rver32]
@="C:\\Program Files\\Common Files\\System\\OLE DB\\sqloledb.dll"
"ThreadingModel"="Both"

[HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}\OLE DB
Provider]
@="Microsoft OLE DB Provider for SQL Server"

[HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}\ProgID]
@="SQLOLEDB.1"

[HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}\VersionI
ndependentProgID]
@="SQLOLEDB"
/* ************************************ */

if is the following entry that the provider enumerator is looking for:

[HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}\OLE DB
Provider]
@="Microsoft OLE DB Provider for SQL Server"

Have a look in the registery on any machine that has MDAC 2.5 or later
installed.
6. Select the Open button, and then select a table from the list
displayed.

No tables are displayed when I select my provider only the following gets
imbedded in my spread sheet:

[oledb]
; Everything after this line is an OLE DB initstring
Provider=CCDFapSource Object;Persist Security Info=False;User
ID="";Data Source=cdf_db;Location=D:\fums\cdf_db;Mode=Read;Extended
Properties=""

Any suggestions???

Now I think we are looking at an oledb provider that does not implement
all of the required interfaces. I hope this isn't taken as pedantic
exercise, but have you had a look at these links:

http://msdn.microsoft.com/library/en-us/oledb/htm/olprappendixd_1.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnado/h
tml/dnadoxtooledbmapping.asp

and specifically, have you implemented the IDBSchemaRowset interface?
This is not a required interface, and, if i recall correctly, it is only
necessary for cases like the one we are looking at - namely an app that
needs to enumerate the tables in your provider's store(i.e. enumerate
the schemas and then get info on each schema). It has been a while
since I have messed with this part of the provider, and I shall look
into it a bit more later this evening, if i get a chance, else i'll
investigate a bit more tomorrow...

regards
roy fine
..
 
D

Duncan Winn

Roy,
Have a look in the registry on any machine that has MDAC 2.5 or later
installed.

When you say registry are you talking about the ProviderName.reg files. My
(atl) provider does not seem to have one, I believe it was registered
automatically. The closest I have come to finding it is a file called
"REGISTRY" which just contains binary data, and a file called .rgs. But I
have a feeling that the provider is registered successfully as I can view it
in Borland Builder's list of available Ole Db providers, and I have
successfully created a client that can access it??? (Using Regedit I can
only find what I showed you last time).
Now I think we are looking at an oledb provider that does not implement
all of the required interfaces.

I am sure this is true!!!!
and specifically, have you implemented the IDBSchemaRowset interface?

I believe I have (to a degree) but I don't really understand what is going
on here (I just went through Lon Fishers article step by step, which told me
what to do but not always why!). In my CDFapSess.h class I have the
following three implementations for:

class CCDFapSessionTRSchemaRowset;
class CCDFapSessionColSchemaRowset;
class CCDFapSessionPTSchemaRowset;

i.e....

class CCDFapSessionTRSchemaRowset :
public CSchemaRowsetImpl< CCDFapSessionTRSchemaRowset, CTABLESRow,
CCDFapSession>
{
public:
BEGIN_PROPSET_MAP(CCDFapSessionTRSchemaRowset)
BEGIN_PROPERTY_SET(DBPROPSET_ROWSET)
PROPERTY_INFO_ENTRY(IAccessor)
PROPERTY_INFO_ENTRY(IColumnsInfo)
PROPERTY_INFO_ENTRY(IConvertType)
PROPERTY_INFO_ENTRY(IRowset)
PROPERTY_INFO_ENTRY(IRowsetIdentity)
PROPERTY_INFO_ENTRY(IRowsetInfo)
PROPERTY_INFO_ENTRY(CANFETCHBACKWARDS)
PROPERTY_INFO_ENTRY(CANHOLDROWS)
PROPERTY_INFO_ENTRY(CANSCROLLBACKWARDS)
PROPERTY_INFO_ENTRY_VALUE(MAXOPENROWS, 0)
PROPERTY_INFO_ENTRY_VALUE(MAXROWS, 0)
END_PROPERTY_SET(DBPROPSET_ROWSET)
END_PROPSET_MAP()

HRESULT Execute(LONG* pcRowsAffected, ULONG, const VARIANT*)
{
USES_CONVERSION;
//CTextFile tf;
CTABLESRow trData;
lstrcpyW(trData.m_szType, OLESTR("TABLE"));
lstrcpyW(trData.m_szDesc, OLESTR("The Text File Table"));
TCHAR szFile[255];
_tcscpy(szFile, _T("c:\\code\\myprov\\sample.txt"));
lstrcpynW(trData.m_szTable, T2OLE(szFile),
SIZEOF_MEMBER(CTABLESRow, m_szTable));
if (!m_rgRowData.Add(trData))
return E_OUTOFMEMORY;
*pcRowsAffected = 1;
return S_OK;
}//END OF Execute

It will look into it further as it is not implemented properly yet.

Thanks,

Duncan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top