📄 otlhandle.cpp
字号:
// OtlHandle.cpp: implementation of the COtlHandle class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "OtlHandle.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
COtlHandle::COtlHandle()
{
ini_otl();
}
COtlHandle::~COtlHandle()
{
fini_otl();
}
//建立数据库连接
bool COtlHandle::ConnectDB(const char * strConn)
{
char strErr[256];
try
{
m_db.set_timeout(60 * 1000);
#if defined OTL_ODBC
m_db.rlogon("UID=ljf;PWD=ljf;DSN=zqms"); // connect to ODBC
#else
m_db.rlogon(strConn);
#endif
}
catch(otl_exception& p)
{ // intercept OTL exceptions
printf(strErr,"%s",p.msg); // print out error message
printf(strErr,"%s",p.stm_text); // print out SQL that caused the error
return false;
}
return true;
}
//直接执行
bool COtlHandle::ExcuteSQL(const char * strSQL)
{
char strErr[256];
try
{
otl_cursor::direct_exec
(
m_db,
strSQL
); // create table
}
catch(otl_exception& p)
{ // intercept OTL exceptions
printf(strErr,"%s",p.msg); // print out error message
printf(strErr,"%s",p.stm_text); // print out SQL that caused the error
return false;
}
return true;
}
//
bool COtlHandle::GetDataSetFromDB(const char * strQuery, otl_stream *pDataSet)
{
char strErr[256];
try
{
otl_stream * i = new otl_stream(50, // buffer size may be > 1
strQuery, // SELECT statement
m_db // connect object
);
pDataSet = i;
pDataSet->get_rpc();
}
catch(otl_exception& p)
{
printf(strErr,"%s",p.msg); // print out error message
printf(strErr,"%s",p.stm_text); // print out SQL that caused the error
return false;
}
return true;
}
void COtlHandle::ini_otl()
{
otl_connect::otl_initialize(); // initialize OCI environment
}
void COtlHandle::fini_otl()
{
m_db.logoff();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -