如何创建数据库时我指定的ODBC访问驱动程序格式 [英] How do I specify the ODBC Access Driver Format when creating the database

查看:213
本文介绍了如何创建数据库时我指定的ODBC访问驱动程序格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C,我想创建使用ODBC通过的 SQLConfigDataSource 功能。

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);

我希望新数据库的文件扩展名被.ACCDB但是当我运行上面的code,我总是得到C:\\ access2007.accdb.mdb。我可以指定从ODBC管理的12.x(ACCDB)或4.x版(MDB)作为在下面的图片,但我怎么通过ODBC API呢?

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?

我可以创建用户DSN,但是我觉得这也是错误的格式,因为我没有测试过。

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.

如何定义使用ODBC /访问API的格式版本?

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

推荐答案

使用CREATE_DBV12:

Use CREATE_DBV12:

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

这篇关于如何创建数据库时我指定的ODBC访问驱动程序格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆