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. CDAORecordset::Find() trouble

CDAORecordset::Find() trouble

Scheduled Pinned Locked Moved C / C++ / MFC
helpannouncementdatabase
2 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.
  • A Offline
    A Offline
    AntonGogolev
    wrote on last edited by
    #1

    Check this out: ... str.Format("[ProductID] = '%s' AND [Date] = #%s#", m_pSet->m_strProductID, COleDateTime::GetCurrentTime().Format(_T("%#m/%#d/%Y"))); lI = pShop->GetRecordCount(); if(pShop->FindLast(str) == 0) { pShop->AddNew(); pShop->m_lEntryID = lI; pShop->m_dtDate = COleDateTime::GetCurrentTime(); pShop->m_strProductID = m_pSet->m_strProductID; pShop->m_lQuantity = lQ; pShop->Update(); } else { pShop->Edit(); pShop->m_lQuantity += lQ; pShop->Update(); } ... Here's the problem. I try to find a record which has a given ProductID and which was created today. Although THERE ARE such records, nothing is ever found. MSDN says one has to use US date format (month-day-year) even if using non-engish version of MS Jet (I'm from Russia :)), bun nothing is said about how the actual format string should look like. The database was created in MS Access 2K and uses short date format (something like 19.06.1994 - that's the sample in Access). Error 207: Error 208

    P 1 Reply Last reply
    0
    • A AntonGogolev

      Check this out: ... str.Format("[ProductID] = '%s' AND [Date] = #%s#", m_pSet->m_strProductID, COleDateTime::GetCurrentTime().Format(_T("%#m/%#d/%Y"))); lI = pShop->GetRecordCount(); if(pShop->FindLast(str) == 0) { pShop->AddNew(); pShop->m_lEntryID = lI; pShop->m_dtDate = COleDateTime::GetCurrentTime(); pShop->m_strProductID = m_pSet->m_strProductID; pShop->m_lQuantity = lQ; pShop->Update(); } else { pShop->Edit(); pShop->m_lQuantity += lQ; pShop->Update(); } ... Here's the problem. I try to find a record which has a given ProductID and which was created today. Although THERE ARE such records, nothing is ever found. MSDN says one has to use US date format (month-day-year) even if using non-engish version of MS Jet (I'm from Russia :)), bun nothing is said about how the actual format string should look like. The database was created in MS Access 2K and uses short date format (something like 19.06.1994 - that's the sample in Access). Error 207: Error 208

      P Offline
      P Offline
      Pir8ofTampa
      wrote on last edited by
      #2

      I myself have had difficulty with short date fields in MS Access. Possible Solutions: Verify (without reformatting) the COleDateTime value that is actually returned from your table. Mine have sometimes included time even though I have set it to be exclusively a date. Also becuase you are using a short date, you must use two digits to express the year so: str.Format("[ProductID] = '%s' AND [Date] = #%s#", m_pSet->m_strProductID, COleDateTime::GetCurrentTime().Format(_T("%#m/%#d/%y"))); Good luck.

      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