c++通过OCCI访问Oracle编程程序错误_CrtIsValidHeapPointer(pUserData)

colystudio 2006-10-17 05:14:06
c++通过OCCI访问Oracle编程程序错误_CrtIsValidHeapPointer(pUserData)
程序代码:
#define WIN32COMMON


#include <iostream>
#include <occi.h>
using namespace oracle::occi;
using namespace std;
#pragma comment(lib, "oraocci10.lib")

int main(void)
{
Environment *env = NULL;
Connection *conn = NULL;
Statement *stmt = NULL;
ResultSet *rs = NULL;
string user;
string passwd;
string db;
user = "ly";
passwd = "a123";
db = "";

try
{
env = Environment::createEnvironment(Environment::OBJECT);
if(env != NULL)
{
conn = env->createConnection (user, passwd, db);
if(conn != NULL)
{
stmt = conn->createStatement("select * from name");
rs = stmt->executeQuery();

while(rs->next())
{
cout << rs->getString(1);
}

stmt->closeResultSet(rs);
}

env->terminateConnection(conn);
}

Environment::terminateEnvironment(env);
}
catch (SQLException e)
{
cout << "Error : ";
cout << e.getMessage() << endl;
}
return 0;
}

工具:VC6+sp6
数据库:oracle10g

Debug版运行到cout << rs->getString(1);时出问题
错误信息:
Debug Assertion Failed!
File:dbgheap.c
Line: 1044
Expression:_CrtIsValidHeapPointer(pUserData)

Release版可以正常运行。
...全文
282 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
筷子哥 2006-12-04
  • 打赏
  • 举报
回复
// !! IMPORTANT NOTE ON WIN32 PLATFORMS !!
// Please note Oracle TAR 2630255:
// "In this bug the application is linked with (multi-threaded "
// "debug C run-time library) MSVCRTD.DLL however, oraocci9.dll "
// is linked with (multi-threaded non-debug C run-time library) MSVCRT.DLL.
//
// The bottom line to fix this if you experience heap assertion errors -
// add msvcprt.lib to your list of link libraries.
// In debug builds (e.g. /MDd), a link to msvcprtd.lib occurs, which appears
// to be the root of the problem.
// Oracle had about 4-5 tickets opened about this, and it doesn't appear it's
// been fixed outside this workaround.
colystudio 2006-10-17
  • 打赏
  • 举报
回复
没人光顾,我自己搞出来了。
爽呀!!!!
MSVCPRT.LIB Multithreaded, dynamic link (import library for MSVCRT.DLL) /MD _MT, _DLL
加上这个就好了
colystudio 2006-10-17
  • 打赏
  • 举报
回复
改为#pragma comment(lib, "oraocci10d.lib")也同样的错误

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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