博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VC6 C/CPP操作ORACLE数据库 clilib方案
阅读量:2095 次
发布时间:2019-04-29

本文共 1502 字,大约阅读时间需要 5 分钟。

//VC6 ORACLE HA-Instant Client-v11.2.0.3.0-x86.rar  ocilib-4.2.0-windows.zip

#include "stdafx.h"
#include "ocilib.h"
#define
OCI_CHARSET_ANSI
#ifdef _MSC_VER
#if defined(OCI_CHARSET_WIDE)
#pragma comment(lib, "ocilibw.lib")
#elif defined(OCI_CHARSET_ANSI)
#pragma comment(lib, "ociliba.lib")
#endif
#endif
#include <iostream>
#include <fstream>
#include <iomanip>
#include <sstream>
int test(void)
{
    OCI_Connection *cn;
OCI_Statement  *st;
    OCI_Resultset  *rs;
//要安装ORACLE Instant Client OCI_Initialize第二个参数可指令此目录
//
char *home="D:\\Program Files\\Oracle\\Instant Client\\BIN";
    if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT | OCI_ENV_CONTEXT)){
printf("OCI_Initialize failure\n");
        return EXIT_FAILURE;
}
    cn = OCI_ConnectionCreate("192.168.1.7/ORCL", "user", "passwd", OCI_SESSION_DEFAULT);
    printf("Server major    version : %i\n",   OCI_GetServerMajorVersion(cn));
    printf("Server minor    version : %i\n",   OCI_GetServerMinorVersion(cn));
    printf("Server revision version : %i\n\n", OCI_GetServerRevisionVersion(cn));
    printf("Connection      version : %i\n\n", OCI_GetVersionConnection(cn));
 st  = OCI_StatementCreate(cn);
    OCI_ExecuteStmt(st, "select table_name from all_tables where owner='RX_DATASERVER'");
    rs = OCI_GetResultset(st);
    while (OCI_FetchNext(rs))
        printf("code: %i, name %s\n", OCI_GetInt(rs, 0)  , OCI_GetString(rs, 1));
    printf("\n%d row(s) fetched\n", OCI_GetRowCount(rs));
    OCI_Cleanup();
    return EXIT_SUCCESS;
}
int main(int argc, char* argv[])
{
printf("Hello World!\n");
test();
getchar();
return 0;
}

转载地址:http://yiuhf.baihongyu.com/

你可能感兴趣的文章
Leetcode Go 《精选TOP面试题》20200628 69.x的平方根
查看>>
leetcode 130. Surrounded Regions
查看>>
【Python】详解Python多线程Selenium跨浏览器测试
查看>>
Jmeter之参数化
查看>>
Shell 和Python的区别。
查看>>
【JMeter】1.9上考试jmeter测试调试
查看>>
【虫师】【selenium】参数化
查看>>
【Python练习】文件引用用户名密码登录系统
查看>>
学习网站汇总
查看>>
【Loadrunner】性能测试报告实战
查看>>
【自动化测试】自动化测试需要了解的的一些事情。
查看>>
【selenium】selenium ide的安装过程
查看>>
【手机自动化测试】monkey测试
查看>>
【英语】软件开发常用英语词汇
查看>>
Fiddler 抓包工具总结
查看>>
【雅思】雅思需要购买和准备的学习资料
查看>>
【雅思】雅思写作作业(1)
查看>>
【雅思】【大作文】【审题作业】关于同不同意的审题作业(重点)
查看>>
【Loadrunner】通过loadrunner录制时候有事件但是白页无法出来登录页怎么办?
查看>>
【English】【托业】【四六级】写译高频词汇
查看>>