How do I specify the ODBC Access Driver Format when creating the database

瘦欲@ 提交于 2019-12-12 18:43:56

问题


Using C, I am trying to create an Access 2007 database file using ODBC by way of the SQLConfigDataSource function.

char szDriverName[] = "Microsoft Access Driver (*.mdb, *.accdb)";
char szAttr[] = "CREATE_DB=c:\access2007.accdb";
SQLConfigDataSource(NULL, ODBC_ADD_DSN, szDriverName, szAttr);

I want the file extension of the new database to be .accdb but when I run the code above, I always get c:\access2007.accdb.mdb. I can specify 12.x (accdb) or 4.x (mdb) from ODBC Admin as in the image below, but how do I do it via ODBC API?

I am able to create the User DSN, however I feel that it is also in the wrong format as I have not tested it.

How do I define the Format Version using ODBC/Access API?


回答1:


Use CREATE_DBV12:

char szDriverName[] = "Microsoft Access Driver (*.mdb, *.accdb)";
char szAttr[] = "CREATE_DBV12=c:\access2007.accdb";
SQLConfigDataSource(NULL, ODBC_ADD_DSN, szDriverName, szAttr);


来源:https://stackoverflow.com/questions/9205633/how-do-i-specify-the-odbc-access-driver-format-when-creating-the-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!