MFC用ADO动态连接msado15.dll时问题

前段时间在用MFC连接数据库做作业,在动态连接msado15.dll时有时会出现下面问题,然后改来改去,还是有时能运行,有时出问题。自己总结了一下自己的错误,在此和大家分享下。

1、导入ADO动态连接库方法:

在工程的stdafx.h中加入如下语句

  #import "c:\program files\commonfiles\system\ado\msado15.dll"  no_namespace  rename("EOF","adoEOF")

上述语句写在同一行,用空格把四部分分割开。

或是如下所示用“\”来换行连接,

#import "c:\program files\commonfiles\system\ado\msado15.dll" \

no_namespace\

rename("EOF","adoEOF")

2、错误

换行书写时,编译器有时会报如下的错误:


--------------------Configuration: LessonSet - Win32 Debug--------------------
Compilingresources...
Compiling...
StdAfx.cpp
c:\users\1\desktop\lessonset\lessonset\stdafx.h(25): warning C4185: ignoring unknown #import attribute'no_namespacerename'
c:\users\1\desktop\lessonset\lessonset\debug\msado15.tlh(481): warning C4146: unary minus operator applied to unsignedtype, result still unsigned
c:\users\1\desktop\lessonset\lessonset\debug\msado15.tlh(1390): error C2629: unexpected 'short ('
c:\users\1\desktop\lessonset\lessonset\debug\msado15.tlh(1390): error C2238: unexpected token(s) preceding ';'
c:\users\1\desktop\lessonset\lessonset\debug\msado15.tlh(3417): error C2629: unexpected 'short ('
c:\users\1\desktop\lessonset\lessonset\debug\msado15.tlh(3417): error C2238: unexpected token(s) preceding ';'


开始遇到这种错误时特别的令人头疼的。程序本是可以运行,但是拷贝到其他文件下就出问题,报上述错误,尤其是在VC6.0编译器中。我认为错误原因是“\”后的空格我们忽略了,忘了写上,然后就把“no_namespace”和“rename("EOF","adoEOF")”连到了一起,引起错误。

我的解决方法是:

1、把项目Debug里的内容全部删除,把语句写到同一行去,然后重新组建工程,这样就可以对msado15.dll重新引用

2、在换行书写时,在“no_namespace”前加上空格,同时在“rename”前也加上空格,避免“no_namespace”和“rename("EOF","adoEOF")”连到一起

这是遇到的问题后自己的解决方法,希望对也遇到这种问题的朋友有个帮助,也希望大家对这种问题有更好的解释。

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值