Is it possible using plain C to compact and repair a MS Access Database through ODBC?
I'm trying the following code, found it in the WEB:
Code:
void CompactAndRepairDB ()
{
RETCODE retcode;
int subscrp;
CHAR szDriver[] = "Microsoft Access Driver (*.mdb)";
CHAR *szAttributes2[] =
// Create the original .mdb file.
{"REPAIR_DB=db.mdb\0\0",
// Compact the file.
"COMPACT_DB=db.mdb db2.mdb General\0\0"};
for (subscrp = 0; subscrp <= ((sizeof szAttributes2 / sizeof(UCHAR *)) - 1); subscrp++)
{
retcode = SQLConfigDataSource (NULL, ODBC_ADD_DSN, szDriver, szAttributes2[subscrp]);
if (retcode != TRUE)
{
for(int i=1;i<=8;i++)
{
DWORD dwcode = NULL;
WORD wlen = 0;
char szerr[SQL_MAX_MESSAGE_LENGTH] = {0};
if (SQLInstallerError((WORD)i, &dwcode, szerr, SQL_MAX_MESSAGE_LENGTH-1, &wlen) == SQL_SUCCESS)
printf ("Code: %u %s\n",dwcode,szerr);
}
}
}
}
After creating the new compacted file I copy it over the old file.
Though when I run the compacting program I get the following error:
Code:
Driver's ConfigDSN, ConfigDriver, or ConfigTranslator failed.
I'm not using an ODBC datasource, only using filenames.
Thanks in advance,