hResult = m_pRecordset->Open ( TEXT("SELECT * FROM LinkmanList"), 
   _variant_t((IDispatch*)(((CUserManagerApp*)AfxGetApp())->m_pConnection), true),
   adOpenDynamic, 
   adLockPessimistic, 
   adCmdText);

解决方案 »

  1.   

    程序在debug下正常,但是一release就报错.
    经检查发现:
    HRESULT hResult = m_pRecordset.CreateInstance (TEXT("ADODB.Recordset"));
    错误出现在这里,何故?
      

  2.   

    m_pRecordset.CreateInstance (__uuidof(Recordset));
      

  3.   

    m_pRecordset.CreateInstance (__uuidof(Recordset));
    创建记录集实例的代码就是这么写的!你的写法是错误的。
      

  4.   

    但是为什么我在debug下运行是正常的呢?
    //***************************************************************************
    // Function Name : InitLinkmanList()
    // Parameter : 
    //
    // Purpose : When user click the group name of the tree view, the 
    // listview show the relative users.  
    //***************************************************************************
    bool CUserManagerDlg::InitLinkmanList(DWORD dwGroupID)
    {
    m_userList.DeleteAllItems (); //***********************************************************************
    _variant_t vID;
    _variant_t vGroupID;
    _variant_t vLinkmanName;
    _variant_t vEmail;
    _variant_t vHandset; try
    {
    // Create the Recordset object
    HRESULT hResult = m_pRecordset.CreateInstance (TEXT("ADODB.Recordset")); if(SUCCEEDED(hResult))
    {
    // Execute the SQL command
    hResult = m_pRecordset->Open ( TEXT("SELECT ID,GroupID,LinkmanName,Email,Handset FROM LinkmanList"), 
       _variant_t((IDispatch*)(((CUserManagerApp*)AfxGetApp())->m_pConnection), true),
       adOpenDynamic, 
       adLockPessimistic, 
       adCmdText); if(SUCCEEDED(hResult))
    {
    m_pRecordset->MoveFirst (); while( !m_pRecordset->adoEOF )
    {
    // Get the record of the GroupName
    vGroupID = m_pRecordset->GetCollect (TEXT("GroupID")); vGroupID.ChangeType (VT_R4);
    if ( (DWORD)(vGroupID.fltVal) != dwGroupID )
    {
    m_pRecordset->MoveNext ();
    continue;
    } // Get the record from the database
    vID = m_pRecordset->GetCollect (TEXT("ID"));
    vLinkmanName = m_pRecordset->GetCollect (TEXT("LinkmanName"));
    vEmail = m_pRecordset->GetCollect (TEXT("Email"));
    vHandset = m_pRecordset->GetCollect (TEXT("Handset")); // Show the information on the dialog
    int nItem = m_userList.InsertItem (0xffff, (_bstr_t)vLinkmanName);

    if(vEmail.vt != VT_NULL)
    {
    m_userList.SetItem (nItem, 1, 1, (_bstr_t)vEmail, NULL, 0, 0, 0);
    } if(vHandset.vt != VT_NULL)
    {
    m_userList.SetItem (nItem, 2, 1, (_bstr_t)vHandset, NULL, 0, 0, 0);
    } // Set the data attached the item in the listctrl
    vID.ChangeType (VT_R4);
    m_userList.SetItemData (nItem, (DWORD)vID.fltVal); // Move the pointer to the next
    m_pRecordset->MoveNext ();
    } }
    else
    {
    return FALSE;
    } }
    else
    {
    return FALSE;
    } }
    // catch the expection error
    catch(_com_error e)
    {
    char cErrorMessage[1024];
            strcpy (cErrorMessage, (char*)(_bstr_t)(e.Description()) );
    AfxMessageBox(cErrorMessage);
            return FALSE;
    } if(m_pRecordset)
    {
    m_pRecordset->Close ();
    m_pRecordset = NULL;
    } return TRUE;
    }请大虾指点!!!
      

  5.   

    TEXT()什么东西,我从未用过你去掉试一试
      

  6.   

    TEXT就是和_T一样的宏命令啊,这个是为了提高兼容性才写的.