15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


How does one combine DAO and OLE Structured Storage?

Dave Bickford -- dave_bickford@compuware.com
Wednesday, April 03, 1996

     Environment: 95 & NT 4.0, using Visual C++ 4.0 or 4.1
     
     
     I am building an application which greatly benefits from MFC's DAO 
     classes.
     
     The problem is my application must also be an OLE server and container 
     with OLE compound file storage.
     
     I'd like to use MFC's OLE support but it doesn't seem to be integrated 
     with their DAO support.
     
     At this point, I've only been able to use the two facilities by 
     allowing each to manage its own file. Thus each of my apps' documents 
     is split into two files. Does anyone know:
     
     1. a way that I could embed the MDB file as an object in the 
     serialized archive file?
     
     or
     
     2. another way of combining MFC's DAO and OLE support such that my 
     documents are stored in single files.
     
     
     Any help would be greatly appreciated,
     
     Dave Bickford




Mike Blaszczak -- mikeblas@msn.com
Saturday, April 06, 1996

----------
From: 	owner-mfc-l@netcom.com on behalf of Dave Bickford
Sent: 	Wednesday, April 03, 1996 9:02 AM

     > Environment: 95 & NT 4.0, using Visual C++ 4.0 or 4.1

Thanks.
     
> I am building an application which greatly benefits from MFC's DAO 
> classes.
> The problem is my application must also be an OLE server and container 
> with OLE compound file storage.
> I'd like to use MFC's OLE support but it doesn't seem to be integrated 
> with their DAO support.

This is mainly because OLE Structured Storage and DAO are aimed at solving two 
completely different problems. Structured Storage is a way for you to write 
file-oriented data into a stream-like storage.  The neat thing is that your 
data can coexist with data from other programs in a way that doesn't make it 
complicate dfor you to change your data storage scheme to compensate for those 
other applications.  DAO, on the other hand, lets you access databases.

There's no inherent relationship between a normal CFIle and a DAO data source 
or an ODBC data source, either.  They're two different ducks.

> At this point, I've only been able to use the two facilities by 
> allowing each to manage its own file. Thus each of my apps' documents 
> is split into two files. Does anyone know:
     
> 1. a way that I could embed the MDB file as an object in the 
> serialized archive file?

You could:

1) Close the DAO objects opened against the MDB file
2) Open the MDB file as a raw, binary CFile     
3) copy the MDB file into your structure storage.
4) Close everything.  Maybe you want to delete the MDB file.

When someone opens the archive file, you could use the reverse steps.

But what if you're using DAO through ODBC to SQL Server or some other remote 
database sysetm?  Maybe it's just that you want to have a link to the database 
in your OLE structured storage.

Maybe you should consider reversing the tables: maybe you should store 
everything in your database and not allow the user to store any sort of file 
data.  You've not provided any background on your application, so it isn't 
possible to make a definitive recommendation.

> 2. another way of combining MFC's DAO and OLE support such that my 
> documents are stored in single files.

It's impossible to answer this side of your question without knowing what your 
application is, how your users want to perceive their data files, what you're 
storing in the database and what you want to store in a structured storage, 
and 
how those two pools of data are related, if at all.

.B ekiM
TCHAR sz[] = _T("These words are my own; I don't speak for Microsoft.");




| Вернуться в корень Архива |