Can't open database file unless filed count matches 
Author Message
 Can't open database file unless filed count matches

I have a Microsoft Access file named Myfile.mdb.

I am using the following code to see if the file has the correct number of

CDaoRecordset set;
CDaoTableDef ( set.m_pDatabase);
int nFieldCount = daoTable.GetFieldCount();    // check for correct count

I have recently added a field (or column) to Myfile.mdb, thus yielding a
correct count of six fields.

I am using GetFieldCount() to determine if a 'new' file is being used. The
old version of Myfile.mdb had only five fields.

Here's the problem.
I had hoped to be able to open the older files (with one less field), then
add the new field with CreateField(). But I get a try/catch CDaoException
indicating I have one too few columns in the file I am trying to open.

Does anyone know how I can open these older files to make my application
backward compatible for my customers? In other words, I want to open the
older Myfile.mdb files and if they have five fields, then one will be added
with CreateField().

Any help would be greatly appreciated.


Sun, 30 Nov 2003 08:35:45 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Can't Read File Unless I Change File Name

2. Beginner [Q] Using Canned File Open/Save dialog

3. can't open file: to many files open

4. fatal error C1083: Cannot open include file: 'excpt.h': No such file or directory

5. Newbie - Compile error (Cannot open include file: 'xmldom.idl': No such file or directory)

6. BSCMAKE: error BK1506 : cannot open file '.\Debug\StdAfx.sbr': No such file or directory

7. How to read file while it's opened as a file number in VB

8. Difference between MRU File Open and Regular File Open

9. Linker cannot open file 'mfc70ud.lib'

10. Cannot open include file: 'crtdbg.h'

11. cannot open include file 'winresrc.h'

12. Trap all 'File Open' requests


Powered by phpBB® Forum Software