难道没人知道?

解决方案 »

  1.   

    支持啊.
    m_pset.CreateInstance("ADODB.Recordset");
    CString strSQL;
    strSQL.Format("select distinct * table1 group by field1");
    m_pset->Open(_variant_t(strSQL),
    _variant_t((IDispatch*)g_pDBConnect,true),
    adOpenStatic,
    adLockOptimistic,
    adCmdText);
    参数要用adCmdText,而不是adCmdTable你哪里出错了?错误提示和代码是怎样的啊?
      

  2.   

    肯定支持嘛,ado怎么可能不支持sql?
      

  3.   

    HRESULT hr = m_pRecordset->Open(_variant_t(strSQL),(IDispatch*)m_pConnection,
    adOpenStatic, adLockOptimistic, adCmdText);就是查询出来的记录集为空
      

  4.   

    记录集为空和支不支持DISTINCT 或group by 没有关系,
    ADO肯定支持了,不过要看你的数据库支不支持了,不过一般数据库都支持
      

  5.   

    我的数据库和ADO都支持,就是不知道为什么,是不是m_pConnection创建的时候有问题?
    m_pConnection->put_CommandTimeout(5);
    HRESULT hr = m_pConnection->Open(_bstr_t(szConnectString),_bstr_t(""),_bstr_t(""),-1);
      

  6.   

    可能是你的szConnectString有问题,下面是我的例子
    _bstr_t source("driver={sqloledb};Server=svrname;DATABASE=Northwind;UID=sa;PWD=");
    _bstr_t user("admin");
    _bstr_t pwd("");
    try{
    hr=m_connection.CreateInstance(_uuidof(Connection));
    if(SUCCEEDED(hr))
    hr=m_connection->Open(source,user,pwd,16);
    else
    MessageBox("Connection Error");
    if(SUCCEEDED(hr))
    hr=m_recordset.CreateInstance(_uuidof(Recordset));
    else
    MessageBox("Open Error");
    if(SUCCEEDED(hr))
    m_fConnected=TRUE;
    else
    m_fConnected=FALSE;
    }
    catch(_com_error &e)
    {
    // MessageBox(e.ErrorMessage());
    AfxMessageBox(e.Description());
    m_fConnected=FALSE;
    }
    if(!m_fConnected)
    MessageBox("ADO数据源初始化失败");