不是有个函数CDaoDatabase::Execute吗?

解决方案 »

  1.   

    _bstr_t string;
    _bstr_t datasource;
      HRESULT hr;
      string="Provider=SQLOLEDB.1;Password=mmmm;Persist Security Info=True;User ID=video;Data Source=";
      
      try
      {
      hr=m_pConnection.CreateInstance(_uuidof(Connection));
      datasource=AfxGetApp()->GetProfileString("jianfei","datasource",0);
      string+=datasource;
      string+=";";
      if(SUCCEEDED(hr))
      { // hr=m_pConnection->Open(
         hr=m_pConnection->Open(
    // _bstr_t(L"Provider=SQLOLEDB.1;Password=vzmm;Persist Security Info=True;User ID=video;Data Source=database;"),
              _bstr_t(string),
         
    _bstr_t(L""),
     _bstr_t(L""),
     adModeUnknown);
       if(SUCCEEDED(hr))
       {
         m_IsConnectionOpen=true;
       }
      }
      }   catch(_com_error &e)
      {
      _bstr_t bstrSource(e.Source());
          _bstr_t bstrDescription(e.Description());
      TRACE("jhljjk");
      AfxMessageBox("ghfjfgjhfhgjhg!");
      return false;
      }
      catch(...)
      {
        TRACE("gjghgjfh" );
             return false;
      }
      return true;
         _RecordsetPtr pRecordset;
      _bstr_t bstrQuery("select * from vid_path");
      _variant_t vRecsAffected(0L);
      pRecordset=m_pConnection->Execute(bstrQuery,
                                   &vRecsAffected,
       adOptionUnspecified)
    兄弟,如果不是新手的话,这些就足够了,可运用自如。