?? otlhandle.cpp
字號(hào):
// OtlHandle.cpp: implementation of the COtlHandle class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "OtlHandle.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
COtlHandle::COtlHandle()
{
ini_otl();
}
COtlHandle::~COtlHandle()
{
fini_otl();
}
//建立數(shù)據(jù)庫連接
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;
}
//直接執(zhí)行
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();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -