这个函数里面,就这一行:bool dbAccessor::Connect_DB()
{
if(m_env ==0)
{
m_env = Environment::createEnvironment(); //error LNK 2019
}
if(m_conn==0){
try {
m_conn=m_env->createConnection(m_szUser,m_szPassword,m_szDbName);
} catch (SQLException& ex) {
m_conn = 0;
cout << "connect to database failed: " << ex.getMessage() << endl;
return false;
}
} return true;
}总是报error LNK 2019,注释掉就没事,但是又需要这一行求高手赐教!^_^
{
if(m_env ==0)
{
m_env = Environment::createEnvironment(); //error LNK 2019
}
if(m_conn==0){
try {
m_conn=m_env->createConnection(m_szUser,m_szPassword,m_szDbName);
} catch (SQLException& ex) {
m_conn = 0;
cout << "connect to database failed: " << ex.getMessage() << endl;
return false;
}
} return true;
}总是报error LNK 2019,注释掉就没事,但是又需要这一行求高手赐教!^_^
#pragma comment(lib, "oraocci10.lib")
现在的新问题是,连接数据库的时候,
m_conn=m_env->createConnection(m_szUser,m_szPassword,m_szDbName);报错:
testDB.exe 中的 0x612f89e9 处未处理的异常: 0xC0000005: 读取位置 0xcccccccc 时发生访问冲突
Connection* pCon = NULL;
Statement* pStmt = NULL;
ResultSet* pResult = NULL; try
{
pEnv = Environment::createEnvironment();
pCon = pEnv->createConnection("scott", "scott", "ora158");
pStmt = pCon->createStatement("select name, age, addr from t_cust");
pResult = pStmt->executeQuery(); while (pResult->next())
{
AddCust(Cust(pResult->getString(1),
pResult->getInt(2),
pResult->getString(3)
)
);
} nRet = 1;
}
catch (SQLException& e)
{
printf(" exception catched when creating database object! code:%d, msg:%s\n", e.getErrorCode(), e.getMessage());
nRet = 0;
}
详细解决方案:
请看我的短文:
http://blog.csdn.net/iihero/archive/2006/08/20/1099908.aspx