Click to See Complete Forum and Search --> : Compacting Access Databases Through ODBC


besjr
January 3rd, 2004, 12:11 AM
I am writing a C application that uses ODBC to access an MSAccess Database. I have MDAC version 2.6 and MSOffice 2000 loaded on my PC. The problem that I'm having is that when I make a call to the SQLConfigDataSource function to compact the database, I get the following error message: "Driver's ConfigDSN, ConfigDriver, or ConfigTranslator failed"

Here is a sample fo the code:

char chbuf[_MAX_PATH];
char szcompact[500];
int i;

strcpy(chbuf,_getcwd(NULL,_MAX_PATH));
free(_getcwd(NULL,_MAX_PATH));
sprintf(szcompact,"COMPACT_DB=%s\\data\\ffmc.mdb %s\\data\\ffmc.mdb\" general\0\0",chbuf,chbuf);
if(!SQLConfigDataSource(NULL,ODBC_CONFIG_DSN,szdriver,szcompact))
{
for(i=1;i<=8;i++)
{
if(SQLInstallerError((WORD)i,&dwcode,szerr,SQL_MAX_MESSAGE_LENGTH-1,&wlen)==SQL_SUCCESS)
{
sprintf(szerrstring,"Code: %u %s",dwcode,szerr);
MessageBox(NULL,"Error Compacting DB",szerrstring,MB_ICONWARNING);
}
};
}


Could someone help me with this and tell me what I'm doing wrong in the SQLConfigDataSource call.

Bobby Simmons