Hello, Lamblion!
If you aren't completely wore out fighting software another possible issue just occurred
to me. The way it occurred to me is I started to provide a quickie little program for you
that just illustrated how simple it is to create an access database with SQLConfigDataSource()
if everything is working as it should. SQLConfigDataSource is the ODBC function that actually
creates the database, and it is the key component of iCreateDB(). As soon as I started to write the code I immediately realized that I hadn't updated the creation string we were feeding into SQLConfigDataSource() to reflect that second '*.accdb' file extension we were putting in the driver description string. Recall I had modified this...
DRIVER="Microsoft Access Driver (*.mdb);"
to this...
DRIVER="Microsoft Access Driver (*.mdb, *.accdb);"
...in the hope that that *.accdb was the addition Access 2010 needed for my program to work. So anyway, here is a real little program for you to try whenever you are interested in this again. I'm hoping it might finally create the database for you so we could get to the next step which is connecting. In the code below iInstallerError was never called because it worked for me but whether it will work for you I don't know but I hope! Just to avoid any possible confusion, all this program should do is create the TestData.mdb database. Also, if it doesn't work the first time, try modifying the database name to TestData.accdb. We hadn't tried that either. I really suspect there is some really small thing going on here the fixing of which will get the whole thing working.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
//Link with MS - odbccp32.lib ; GNU MinGW - libodbccp32.a
#include <windows.h>
#include <stdio.h>
#include <odbcinst.h>
unsigned int iInstallerError()
{
DWORD pErr;
char szErrMsg[512];
WORD cbMsgBuffer=512;
WORD cbRet;
WORD wErrNum=1;
while(SQLInstallerError(wErrNum,&pErr,szErrMsg,cbMsgBuffer,&cbRet)!=SQL_NO_DATA)
{
printf("wErrNum = %d\t",wErrNum);
printf("szErrMsg = %s\n",szErrMsg);
wErrNum++;
};
return (unsigned int)pErr;
}
int main()
{
char szBuffer[512],szCreate[512];
strcpy(szCreate,"CREATE_DB="); //SQLConfigDataSource() just basically takes a few
GetCurrentDirectory(512,szBuffer); //parameters the most important of which is the
strcat(szCreate,szBuffer); //path and name of the database you want created
strcat(szCreate, "\\TestData.mdb"); //and it creates the file.
printf("%s\n",szCreate); // <!!!>
if(SQLConfigDataSource(0,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb, *.accdb)",szCreate))
printf("SQLConfigDataSource() returned TRUE!\n");
else
printf("iInstallerError() = %d\n",iInstallerError());
getchar();
return 0;
}
/*
Output:
========================================================
CREATE_DB=C:\Code\CodeBlks\ConfigDataSource\TestData.mdb
SQLConfigDataSource() returned TRUE!
*/
|