connPtr->Open(strConntion, ...)
strConntion = ?

解决方案 »

  1.   

    give u a collection of connection strings
    http://www.codeproject.com/database/ConnectionStrings.aspOLE DB Provider for Oracle (from Oracle)For Standard Security:strConnect = _T("Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;"
            "User Id=myUsername;Password=myPassword;");For a Trusted Connection:OS Authenticated connect setting user ID to "/"strConnect = _T("Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;"
       "User Id=/;Password=;");OS Authenticated connect using OSAuthentstrConnect = _T("Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;")Note: "Data Source=" must be set to the appropriate Net8 name which is known to the naming method in use. For example, for Local Naming, it is the alias in the tnsnames.ora file; for Oracle Names, it is the Net8 Service Name.For more information, see: Oracle Provider for OLE DB Developer's Guide
      

  2.   

    Data Source 具体是指什么?谢谢!
      

  3.   

    m_pConnection->Open("Provider=OraOLEDB.Oracle.1;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xxx.xxx.xxx)(PORT=1526))(CONNECT_DATA=TEST));User ID=adm;Password=adm","","",adModeUnknown);或
    m_pConnection->Open("Provider=OraOLEDB.Oracle.1;Data Source=TEST;User ID=adm;Password=adm","","",adModeUnknown);一种不需要配置oralce客户端数据库服务名我认为一种方法好,但还是需要安装oracle客户端,以后提问之前,先搜搜
    不知道那位人兄有不安装oralce端的解决方案
      

  4.   

    #include <StdAfx.h>
    #include "AdoDBAccess.h"//定义结果记录集指针
    _RecordsetPtr m_pRecordset;//定义数据库连接指针
    _ConnectionPtr m_pConnection;//连接数据库
    bool InitInstance()
    {
    bool flag = FALSE;
    //AfxOleInit();///初始化COM库
    ::CoInitialize(NULL);
    ////////////连接数据库//////////////
    HRESULT hr;
    try
    {
    hr = m_pConnection.CreateInstance("ADODB.Connection");///创建Connection对象
    if(SUCCEEDED(hr))
    {
    hr = m_pConnection->Open("Provider=OraOLEDB.Oracle;Data Source=oracle9i","pop","pop",adModeUnknown);
    flag = TRUE;
    }
    }
    catch(_com_error e)///捕捉异常
    {
    CString errormessage;
    errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
    AfxMessageBox(errormessage);///显示错误信息
    return FALSE;

    return flag;
    }
    _RecordsetPtr GetRecorderSet(char* v_sql,_ConnectionPtr connection)
    {
    try
    {
    m_pRecordset.CreateInstance("ADODB.Recordset");
    m_pRecordset->Open(v_sql,_variant_t((IDispatch*)connection,true),adOpenStatic,adLockOptimistic,adCmdText);
    }
    catch(_com_error e)///捕捉异常
    {
    AfxMessageBox("读取数据库失败!");///显示错误信息
    }
    return m_pRecordset;
    }//关闭记录集
    void CloseRecordSet(bool m_bSuccess)
    {
    if(m_bSuccess)
    {
    m_pRecordset->Update();
    m_pRecordset->Close();
    m_pRecordset = NULL;
    }
    }//关闭连接
    void CloseInstance() 
    {
    if(m_pConnection->State)
    {
     m_pConnection->Close(); ///如果已经打开了连接则关闭它
     m_pConnection = NULL;
    }
    }//关闭OLE COM 库
    void CloseOleCom()
    {
    ::CoUninitialize();
    }
      

  5.   

    Typical Connection String
    A typical connection string for this provider is:"Provider=MSDAORA;Data Source=serverName;User ID=MyUserID; Password=MyPassword;"
    The string consists of these keywords:Keyword Description 
    Provider Specifies    the OLE DB Provider for Oracle. 
    Data Source           Specifies the name of a server. 
    User ID               Specifies the user name. 
    Password              Specifies the user password.