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