当前位置: 首页>>代码示例>>C++>>正文


C++ Connection::Establish方法代码示例

本文整理汇总了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();
    }
开发者ID:psadusumilli,项目名称:ignite,代码行数:31,代码来源:odbc.cpp

示例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();
    }
开发者ID:psadusumilli,项目名称:ignite,代码行数:55,代码来源:odbc.cpp


注:本文中的Connection::Establish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。