这个函数里面,就这一行: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,注释掉就没事,但是又需要这一行求高手赐教!^_^

解决方案 »

  1.   

    错误 1 error LNK2019: 无法解析的外部符号 "public: static class oracle::occi::Environment * __cdecl oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__cdecl*)(void *,unsigned int),void * (__cdecl*)(void *,void *,unsigned int),void (__cdecl*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@SAPAV123@W4Mode@123@PAXP6APAX1I@ZP6APAX11I@ZP6AX11@Z@Z),该符号在函数 "public: bool __thiscall dbAccessor::Connect_DB(void)" (?Connect_DB@dbAccessor@@QAE_NXZ) 中被引用 oracle.obj testDB
      

  2.   

    上面的问题加上下面这句话就对了。
    #pragma comment(lib, "oraocci10.lib")
    现在的新问题是,连接数据库的时候,
    m_conn=m_env->createConnection(m_szUser,m_szPassword,m_szDbName);报错:
    testDB.exe 中的 0x612f89e9 处未处理的异常: 0xC0000005: 读取位置 0xcccccccc 时发生访问冲突
      

  3.   

    m_conn=m_env->createConnection(m_szUser,m_szPassword,m_szDbName);用户名、密码、服务名,是不是错的,连不上数据库?我这里这样写是好的: Environment *pEnv = NULL; 
    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;
    }
      

  4.   

    看了上边的东东,显然不是代码本身的问题,而是你编译以及链接选项设置的问题。
    详细解决方案:
    请看我的短文:

    http://blog.csdn.net/iihero/archive/2006/08/20/1099908.aspx