这些日子被 oracle整得快不行了。又是proC,proC的文件简直和密码一样,偏偏装了10g,结果调试啥的非常不方便,建议要是编程的话还是9i的为好。

 

又要求用otl连接数据库。搞了半天,才晓得在 工具-选项-VC++目录—引用文件添加入"D:\oracle\product\10.2.0\db_1\OCI\lib\MSVC" ---oci.lib(这里我把oci.lib给弄出来,硬是不行,怪了)。同时也要找到安装目录下的ori.h。同样的指引过去。

到这个时候。我tmd的才实现可以登录数据库。代码是网上的范例,难的是这个过程。过程明白了一切就明白了

 

 std; 
#include <stdio.h> 
//下面这个和你的数据库版本一致,同时otl4.h中也要把部分注释掉的取消才行
#define OTL_ORA10G_R2 // Compile OTL 4.0/OCI9i 
#define OTL_ORA_TIMESTAMP // enable Oracle 9i TIMESTAMPs [with [local] time zone] 
#include 
"otlv4.h" // include the OTL 4.0 header file 

otl_connect db; 
// connect object 


int main() 

    otl_connect::otl_initialize(); 
// initialize OCI environment  
    try 
    { 
        db.rlogon(
"mzzbs/mzzbsadmin@ORA_TEST_16"); // connect to Oracle  
        cout<<"Connect to Database"<<endl; 
        getchar();
    } 
    
catch(otl_exception& p) 
    {  
        
// intercept OTL exceptions  
        cerr<<p.msg<<endl; // print out error message  
        cerr<<p.stm_text<<endl; // print out SQL that caused the error  
        cerr<<p.sqlstate<<endl; // print out SQLSTATE message  
        cerr<<p.var_info<<endl; // print out the variable that caused the error  
    } 
  

    db.logoff(); 
// disconnect from Oracle 


    
return 0

//

相关文章:

  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-22
  • 2021-09-11
  • 2021-07-20
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案