Click to See Complete Forum and Search --> : How to use CompactDatabase with non .mdb files ?


ans
April 20th, 1999, 10:51 AM
I use DAO.
My application creates local files which are mdb files. When I create these files, I give them another extension rather than .mdb (let's say .pol).

I want to use CompactDatabase, but it seems that this method works only if the extension of the source and destination files is .mdb and no other one.

When I use CompactDatabase with FileSrc.pol and FileDest.pol it tells me that it doesn't find the ISAM pilot. It shouldn't look for any ISAM pilot as my files are Microsoft Jet databases.

Does anybody knoes how to work around the problem ?

vshewale
October 1st, 2001, 05:15 AM
Hi..
I am a university student and want to use Access DB as backend in my VC++ application.
For that I want to compact the DB(i.e. MDB file)
to another .mdb file.
Can u please let me know , how it is done?
Thnx in advance
Regards
Vishal shewale
vshewale@vsnl.com

ans
October 1st, 2001, 07:33 AM
You should be able to do it, doing like that :

CDaoDatabase daoBDD;
CString szYourSourceFile = "C:\MySourceFile.XXX"
CString szYourDestFile = "C:\MyDestFile.MDB"


// To be sure that the CompactDatabase works and understands that
// the file is an Access Base, you MUST pass it a ";pwd=" string
// as a password.
CString szConnection = ";pwd=" + "Your password";

TRY
{
// La méhode pour encrypter est une méthode de CDAOWorkspace
daoBDD.m_pWorkspace->CompactDatabase( szYourSourceFile,
szYourDestFile,
dbLangGeneral,
dbEncrypt,
szConnection);
}

CATCH(CDaoException, pException)
{
// Do whatever you want
}
END_CATCH
}