I solved this once before using VC++ and CDaoRecordSet, but I am looking for
a better solution - even though I have the sinking feeling that what I am
attempting to accomplish is not possible.

Here is the issue (at least a pared down version of it):

My VC++ MFC application has a Microsoft Access file Networks.mdb which
currently has six fields.

The problem arises when I want to add another (or seventh) field.

There is no problem updating the CPP (or class file) for this file -
Networks.mdb. I am able to successfully bind a new variable for the new
field.

But of course this means I can no longer read the old MDB file without
throwing an exception. Which is not unexpected since the number of elements
(6) no longer matches the new class file where m_nFields is now set to 7.

So my question is there a way to open this mismatched MDB file at runtime so
that I can retrieve the records and safe them in the new MDB file. Of course
the added problem is both MDB files have the same name.

TIA.

Michael T.

Re: Cannot add fields at runtime to a CDaoRecordSet class by Scott

Scott
Sat Jun 19 10:02:47 CDT 2004

Michael_99 wrote:
> I solved this once before using VC++ and CDaoRecordSet, but I am looking for
> a better solution - even though I have the sinking feeling that what I am
> attempting to accomplish is not possible.
>
> Here is the issue (at least a pared down version of it):
>
> My VC++ MFC application has a Microsoft Access file Networks.mdb which
> currently has six fields.
>
> The problem arises when I want to add another (or seventh) field.
>
> There is no problem updating the CPP (or class file) for this file -
> Networks.mdb. I am able to successfully bind a new variable for the new
> field.
>
> But of course this means I can no longer read the old MDB file without
> throwing an exception. Which is not unexpected since the number of elements
> (6) no longer matches the new class file where m_nFields is now set to 7.
>
> So my question is there a way to open this mismatched MDB file at runtime so
> that I can retrieve the records and safe them in the new MDB file. Of course
> the added problem is both MDB files have the same name.
>
> TIA.
>
> Michael T.
>
>
>

See "DAO Recordset: Binding Records Dynamically" in MSDN.

--
Scott McPhillips [VC++ MVP]