vc下用访问数据库的一个问题

oyljerry 2004-07-13 05:08:05
我编译了一个用dao访问数据库的简单例子,部分代码如下:
AfxGetModuleState()->m_dwVersion = 0x0601;
AfxDaoInit();

CDaoDatabase mydatabase;
mydatabase.Open("D:\\db1.mdb");
printf("version: %s\n",mydatabase.GetVersion());
mydatabase.Close();


发现一个问题:
当我在settings中选择using MFC in a shared dll方式时,编译正确,
但我用using MFC in a static library编译时,就有错误了:error C2039: 'm_dwVersion' : is not a member of 'AFX_MODULE_STATE'
这是什么原因呢??
是不是用DAO时,必须为using MFC in a shared dll啊
如果我想用using MFC in a static library方式,来用DAO访问数据库,有没有什么办法呢???
...全文
239 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
oyljerry 2004-07-16
  • 打赏
  • 举报
回复
不知ADO和OLEDB是不是也必须用using MFC in a shared dll这个方式呢??
taianmonkey 2004-07-15
  • 打赏
  • 举报
回复

// Add these lines to the top of daocore.cpp
#include "daoimpl.h"
#define _countof(array) (sizeof(array)/sizeof(array[0]))
#undef _MFC_VER
#define _MFC_VER 0x0601


oyljerry 2004-07-15
  • 打赏
  • 举报
回复
vc6可以访问access 2k啊,不过要改那个jet引擎吧!!
但是不知道为什么编译一定要md的
oyljerry 2004-07-15
  • 打赏
  • 举报
回复
taianmonkey,你的方法还是只能用using MFC in a shared dll,不能用static library的方式!!
编译的时候出错:'m_dwVersion' : is not a member of 'AFX_MODULE_STATE'
taianmonkey 2004-07-15
  • 打赏
  • 举报
回复
Steps to Create Access 2000 Database
Create an MFC dialog box-based application.


Add a command button to the dialog box resource. Add the following code to the command button handler:



AfxGetModuleState()->m_dwVersion = 0x0601;
CDaoDatabase db;
db.Create("NewDatabase.mdb",dbLangGeneral,0x40);

Add the following code to Stdafx.h:



#ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h> // MFC DAO database classes.
#endif // _AFX_NO_DAO_SUPPORT
Compile and run your application.





REFERENCES
For additional information, please see the following article in the Microsoft Knowledge Base:

236991 PRB: Unrecognized Database Format Error with Access 2000 Database

Additional query words: Access2000 Office2000 Office 2000 DatabaseTypeEnum dbVersion40

Keywords : kbDAOsearch kbDatabase kbMFC kbOffice2000 kbGrpDSVCDB kbDAO360
Issue type : kbhowto
Technology : kbVCsearch kbAudDeveloper kbVC32bitSearch kbVCPE600 kbVCEE600 kbVCLE600

sbqjhipr 2004-07-14
  • 打赏
  • 举报
回复
上最vc6 的dao只可以用97以前的access
oyljerry 2004-07-14
  • 打赏
  • 举报
回复
啊,这样的啊,娜在vc6下,是不是只能用MFC ODBC了?
佑生 2004-07-14
  • 打赏
  • 举报
回复
vc6中必须选择using MFC in a shared dll方式才行。否则,请用visual studio.net。

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧