DAO + Access MDB file + CompactDatabase? 
Author Message
 DAO + Access MDB file + CompactDatabase?

 How can I compact an Access MDB file from a VC++ program?

 I wrote a program that works with an access database (.MDB)
using CDao* classes in MFC. The database manager is MS DAO
Jet 3.5 (included in VC++ 5.0 CD), the OS is Win95.
 There is a Compact function that I cannot use from Dao. This is
the CompactDatabase method of CDaoWorkspace. (It's very needful
for an Access MDB file.) I see a "Could not find an installable
ISAM" message box every time I call the CompactDatabase function.
Could anybody help me? Thanx:

        Robert



Wed, 11 Jul 2001 03:00:00 GMT  
 DAO + Access MDB file + CompactDatabase?

Quote:

>  How can I compact an Access MDB file from a VC++ program?

>  I wrote a program that works with an access database (.MDB)
> using CDao* classes in MFC. The database manager is MS DAO
> Jet 3.5 (included in VC++ 5.0 CD), the OS is Win95.
>  There is a Compact function that I cannot use from Dao. This is
> the CompactDatabase method of CDaoWorkspace. (It's very needful
> for an Access MDB file.) I see a "Could not find an installable
> ISAM" message box every time I call the CompactDatabase function.
> Could anybody help me? Thanx:

>         Robert

Could not find installable Isam refers to an incorrect path(name)
in the most cases.

Hans



Fri, 13 Jul 2001 03:00:00 GMT  
 DAO + Access MDB file + CompactDatabase?
Does compact databases also rebuild the index file?  If not how do you do
that in DAO

thanks


Quote:
> How can I compact an Access MDB file from a VC++ program?

> I wrote a program that works with an access database (.MDB)
>using CDao* classes in MFC. The database manager is MS DAO
>Jet 3.5 (included in VC++ 5.0 CD), the OS is Win95.
> There is a Compact function that I cannot use from Dao. This is
>the CompactDatabase method of CDaoWorkspace. (It's very needful
>for an Access MDB file.) I see a "Could not find an installable
>ISAM" message box every time I call the CompactDatabase function.
>Could anybody help me? Thanx:

> Robert



Sun, 15 Jul 2001 03:00:00 GMT  
 DAO + Access MDB file + CompactDatabase?

Quote:
>>  How can I compact an Access MDB file from a VC++ program?

Here's the code I use to Compress & Repair an Access database...

void CHbcalcApp::OnToolsDatabaseCompress()
{ BeginWaitCursor();
 CDaoWorkspace pWS;
 CString sDest;
 char szPathFileName[_MAX_PATH];
 char szPath[_MAX_PATH];
 if ( !GetDatabaseName( szPathFileName ) )
  return;
 char drive[_MAX_DRIVE];
 char dir[_MAX_DIR];
 char fname[_MAX_FNAME];
 char ext[_MAX_EXT];
 _splitpath( (char *)szPathFileName, drive, dir, fname, ext );
 _makepath( szPath, drive, dir, "temp", "mdb" );
 sDest = szPath;
 try
 { pWS.Create("Temp1","Admin","");
  pWS.CompactDatabase( szPathFileName, sDest, dbLangGeneral, 0);
//,"pwd=adminpw"
  pWS.Close();
 }
 catch( CDaoException* e )
 { DisplayDaoException( e );
  e->Delete();
  return;
 }
 DeleteFile( szPathFileName );
 CopyFile( sDest, szPathFileName, FALSE );
 DeleteFile( sDest );
 EndWaitCursor();
 CString sMsg;
 AfxFormatString2(sMsg, IDS_DatabaseRepairCompressOK, "compress",
szPathFileName);
 AfxMessageBox(sMsg, MB_OK|MB_ICONINFORMATION,
IDS_DatabaseRepairCompressOK);

Quote:
}

void CHbcalcApp::OnToolsDatabaseRepair()
{ BeginWaitCursor();
 CDaoWorkspace pWS;
 char szPathFileName[_MAX_PATH];
 if ( !GetDatabaseName( szPathFileName ) )
  return;
 try
 { pWS.Create( "Temp2", "Admin", "" );
  pWS.RepairDatabase( szPathFileName );
  pWS.Close();
 }
 catch( CDaoException* e )
 { DisplayDaoException( e );
  e->Delete();
  return;
 }
// OnToolsDatabaseCompress();
 EndWaitCursor();
 CString sMsg;
 AfxFormatString2(sMsg, IDS_DatabaseRepairCompressOK, "repair",
szPathFileName);
 AfxMessageBox(sMsg, MB_OK|MB_ICONINFORMATION,
IDS_DatabaseRepairCompressOK);
Quote:
}



Wed, 18 Jul 2001 03:00:00 GMT  
 DAO + Access MDB file + CompactDatabase?


Fri, 19 Jun 1992 00:00:00 GMT  
 DAO + Access MDB file + CompactDatabase?
 I think the compact method must rebuilds the indexes, because the Jet
engine stores all part of database in one file (you can compact .MDB),
and there aren't any method about creating indexes.

 Robert



Quote:
> Does compact databases also rebuild the index file?  If not how do you do
> that in DAO

> thanks



Sat, 21 Jul 2001 03:00:00 GMT  
 DAO + Access MDB file + CompactDatabase?


Fri, 19 Jun 1992 00:00:00 GMT  
 DAO + Access MDB file + CompactDatabase?

Quote:

>Does compact databases also rebuild the index file?  If not how do you do
>that in DAO

>thanks



>> How can I compact an Access MDB file from a VC++ program?

>> I wrote a program that works with an access database (.MDB)
>>using CDao* classes in MFC. The database manager is MS DAO
>>Jet 3.5 (included in VC++ 5.0 CD), the OS is Win95.
>> There is a Compact function that I cannot use from Dao. This is
>>the CompactDatabase method of CDaoWorkspace. (It's very needful
>>for an Access MDB file.) I see a "Could not find an installable
>>ISAM" message box every time I call the CompactDatabase function.
>>Could anybody help me? Thanx:

>> Robert

>Try this: close the database(you most be sure nobody is using the database) and then call CompactDatabase();

with the database source path, and the destination path.
(Note source Path most be different from destination path)
m_Database->Close();
try
{
        m_Database->m_pWorkspace->CompactDatabase(GetDBPath(), strDestinationPath);

Quote:
}

-----------------** -- Posted from CodeGuru -- **-----------------
http://www.codeguru.com/    The website for Visual C++ programmers.


Thu, 09 Aug 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. DAO - Password protected .MDB file access

2. Strange ODBC errors using DAO to access linked tables in Access .MDB

3. Can I access an access (mdb) file within DOS

4. accessing outlook from vc (via access mdb file)

5. how to open ms access 2000 mdb via vc++ and dao

6. Converting Access 97 MDB file to Access 2000

7. DAO, ODBC with an Access MDB

8. Password processing in DAO (MDB files, programmatically)

9. Adding records to a MDB file using DAO

10. DAO: Two clients reading MDB on a file server

11. dao and access2000 mdb files

12. DAO: Two clients reading MDB on a file server

 

 
Powered by phpBB® Forum Software