控制台程序里面使用数据库的问题

gooyan 2004-08-05 08:18:15
控制台程序选择了支持MFC
使用带MFC的consol程序
在stdafx.h中引入:
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
然后再tmain中使用
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}

结果
F:\try\regedit\ReadPolicy_con\ReadPolicy_con.cpp(22) : error C2065: 'AfxSocketInit' : undeclared identifier
...全文
42 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
gooyan 2004-08-05
  • 打赏
  • 举报
回复
手误,呵呵。应该是AfxOleInit()

不过请看看是AfxOleInit的问题

http://community.csdn.net/Expert/topic/3247/3247082.xml?temp=.9609339
kvw3000 2004-08-05
  • 打赏
  • 举报
回复
要使用AfxSocketInit()必须加入
#include "afxsock.h"
kvw3000 2004-08-05
  • 打赏
  • 举报
回复
AfxSocketInit
BOOL AfxSocketInit( WSADATA* lpwsaData = NULL );

Return Value

Nonzero if the function is successful; otherwise 0.

Parameters

lpwsaData

A pointer to a WSADATA structure. If lpwsaData is not equal to NULL, then the address of the WSADATA structure is filled by the call to ::WSAStartup. This function also ensures that ::WSACleanup is called for you before the application terminates.

Remarks

Call this function in your CWinApp::InitInstance override to initialize Windows Sockets.

See Also CWinApp::InitInstance

这个函数与数据库操作无关
//////////////////////////////////////////////////////////////////////////////

使用ado要:
CoInitialize(0); //初始化COM库

文档:
http://www.vckbase.com/document/listdoc.asp?mclsid=11&sclsid=1105

代码:
http://www.vckbase.com/code/listcode.asp?mclsid=11&sclsid=1105

4,012

社区成员

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

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