本文整理汇总了C++中Connection::Establish方法的典型用法代码示例。如果您正苦于以下问题:C++ Connection::Establish方法的具体用法?C++ Connection::Establish怎么用?C++ Connection::Establish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::Establish方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SQLConnect
SQLRETURN SQLConnect(SQLHDBC conn,
SQLCHAR* serverName,
SQLSMALLINT serverNameLen,
SQLCHAR* userName,
SQLSMALLINT userNameLen,
SQLCHAR* auth,
SQLSMALLINT authLen)
{
using odbc::Connection;
using odbc::config::Configuration;
using utility::SqlStringToString;
LOG_MSG("SQLConnect called\n");
Connection *connection = reinterpret_cast<Connection*>(conn);
if (!connection)
return SQL_INVALID_HANDLE;
odbc::config::Configuration config;
std::string dsn = SqlStringToString(serverName, serverNameLen);
LOG_MSG("DSN: " << dsn);
odbc::ReadDsnConfiguration(dsn.c_str(), config);
connection->Establish(config);
return connection->GetDiagnosticRecords().GetReturnCode();
}
示例2: SQLDriverConnect
SQLRETURN SQLDriverConnect(SQLHDBC conn,
SQLHWND windowHandle,
SQLCHAR* inConnectionString,
SQLSMALLINT inConnectionStringLen,
SQLCHAR* outConnectionString,
SQLSMALLINT outConnectionStringBufferLen,
SQLSMALLINT* outConnectionStringLen,
SQLUSMALLINT driverCompletion)
{
using odbc::Connection;
using odbc::diagnostic::DiagnosticRecordStorage;
using utility::SqlStringToString;
using utility::CopyStringToBuffer;
UNREFERENCED_PARAMETER(windowHandle);
LOG_MSG("SQLDriverConnect called");
if (inConnectionString)
LOG_MSG("Connection String: [" << inConnectionString << "]");
Connection *connection = reinterpret_cast<Connection*>(conn);
if (!connection)
return SQL_INVALID_HANDLE;
std::string connectStr = SqlStringToString(inConnectionString, inConnectionStringLen);
odbc::config::Configuration config;
config.FillFromConnectString(connectStr);
std::string dsn = config.GetDsn();
if (!dsn.empty())
odbc::ReadDsnConfiguration(dsn.c_str(), config);
connection->Establish(config);
const DiagnosticRecordStorage& diag = connection->GetDiagnosticRecords();
if (!diag.IsSuccessful())
return diag.GetReturnCode();
size_t reslen = CopyStringToBuffer(connectStr,
reinterpret_cast<char*>(outConnectionString),
static_cast<size_t>(outConnectionStringBufferLen));
if (outConnectionStringLen)
*outConnectionStringLen = static_cast<SQLSMALLINT>(reslen);
if (outConnectionString)
LOG_MSG(outConnectionString);
return diag.GetReturnCode();
}