Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. OLE DB and IRowsetChange::SetData

OLE DB and IRowsetChange::SetData

Scheduled Pinned Locked Moved C / C++ / MFC
databasecomhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bret Faller
    wrote on last edited by
    #1

    Hello, I'm trying to write an OLE DB Wrapper class and have created a function called SetStringFieldValue and inside that function I need to set 1 columns data to the string passed to the function. I have yet to find any examples of SetData anywhere and for some reason its not working for me. Any help is greatly appreciated. void COleDBWrapper::SetStringFieldValue(int nIndex, LPCTSTR lpszValue) { CString strValue(lpszValue); IRowsetChange* pIRowsetChange = (IRowsetChange*)m_pUnkRowsetChange; IRowsetUpdate* pIRowsetUpdate = (IRowsetUpdate*)m_pUnkRowsetUpdate; IAccessor* pIAccessor = NULL; HACCESSOR hAccessor; ULONG cBindings = 1; DBBINDING rgBinding[1]; memset(rgBinding, 0, sizeof(DBBINDING)); char szValue[50]; _tcscpy(szValue, strValue.GetBuffer(0)); rgBinding[0].iOrdinal = nIndex; rgBinding[0].dwPart = DBPART_VALUE|DBPART_STATUS|DBPART_LENGTH; rgBinding[0].obLength = (strValue.GetLength() + 1) * sizeof(TCHAR); rgBinding[0].obStatus = (strValue.GetLength() + 1) * sizeof(TCHAR); (CString)rgBinding[0].obValue = szValue; // -- DOESN'T DO JACK! -- // rgBinding[0].wType = DBTYPE_STR; rgBinding[0].pTypeInfo = NULL; rgBinding[0].pObject = NULL; rgBinding[0].pBindExt = NULL; rgBinding[0].dwMemOwner = DBMEMOWNER_CLIENTOWNED; rgBinding[0].cbMaxLen = (strValue.GetLength() + 1) * sizeof(TCHAR); rgBinding[0].dwFlags = 0; HRESULT hr = m_pUnkRowset->QueryInterface(IID_IAccessor, (void**)&pIAccessor); if (FAILED(hr)) return; hr = pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, 1, rgBinding, 0, &hAccessor, NULL); if (FAILED(hr)) return; hr = pIRowsetChange->SetData(m_hRow, hAccessor, szValue); // hr is ALWAYS DB_E_ERRORSOCCURRED } Bret Faller Odyssey Computing, Inc.

    T 1 Reply Last reply
    0
    • B Bret Faller

      Hello, I'm trying to write an OLE DB Wrapper class and have created a function called SetStringFieldValue and inside that function I need to set 1 columns data to the string passed to the function. I have yet to find any examples of SetData anywhere and for some reason its not working for me. Any help is greatly appreciated. void COleDBWrapper::SetStringFieldValue(int nIndex, LPCTSTR lpszValue) { CString strValue(lpszValue); IRowsetChange* pIRowsetChange = (IRowsetChange*)m_pUnkRowsetChange; IRowsetUpdate* pIRowsetUpdate = (IRowsetUpdate*)m_pUnkRowsetUpdate; IAccessor* pIAccessor = NULL; HACCESSOR hAccessor; ULONG cBindings = 1; DBBINDING rgBinding[1]; memset(rgBinding, 0, sizeof(DBBINDING)); char szValue[50]; _tcscpy(szValue, strValue.GetBuffer(0)); rgBinding[0].iOrdinal = nIndex; rgBinding[0].dwPart = DBPART_VALUE|DBPART_STATUS|DBPART_LENGTH; rgBinding[0].obLength = (strValue.GetLength() + 1) * sizeof(TCHAR); rgBinding[0].obStatus = (strValue.GetLength() + 1) * sizeof(TCHAR); (CString)rgBinding[0].obValue = szValue; // -- DOESN'T DO JACK! -- // rgBinding[0].wType = DBTYPE_STR; rgBinding[0].pTypeInfo = NULL; rgBinding[0].pObject = NULL; rgBinding[0].pBindExt = NULL; rgBinding[0].dwMemOwner = DBMEMOWNER_CLIENTOWNED; rgBinding[0].cbMaxLen = (strValue.GetLength() + 1) * sizeof(TCHAR); rgBinding[0].dwFlags = 0; HRESULT hr = m_pUnkRowset->QueryInterface(IID_IAccessor, (void**)&pIAccessor); if (FAILED(hr)) return; hr = pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, 1, rgBinding, 0, &hAccessor, NULL); if (FAILED(hr)) return; hr = pIRowsetChange->SetData(m_hRow, hAccessor, szValue); // hr is ALWAYS DB_E_ERRORSOCCURRED } Bret Faller Odyssey Computing, Inc.

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      I'm trying to write an OLE DB Wrapper class It sounds like reinventing the wheel - can't you use ATL OLEDB consumer templates? hr is ALWAYS DB_E_ERRORSOCCURRED IErrorRecords should give you more detailed information. See DBViewer sample for details. You may also check the status variables associated with fields. Tomasz Sowinski -- http://www.shooltz.com

      B 1 Reply Last reply
      0
      • T Tomasz Sowinski

        I'm trying to write an OLE DB Wrapper class It sounds like reinventing the wheel - can't you use ATL OLEDB consumer templates? hr is ALWAYS DB_E_ERRORSOCCURRED IErrorRecords should give you more detailed information. See DBViewer sample for details. You may also check the status variables associated with fields. Tomasz Sowinski -- http://www.shooltz.com

        B Offline
        B Offline
        Bret Faller
        wrote on last edited by
        #3

        IErrorRecords::GetDescription and GetSource both give me "M" so they were no help. Also, I am writing my own wrapper class because the templates are ok but they are still too primative. Thank you for your response. Bret Faller Odyssey Computing, Inc.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups