Microsoft KB Archive/294164

= BUG: Jet Truncates DBTIMESTAMP Fraction Element Without Warning =

Article ID: 294164

Article Last Modified on 7/19/2001

-

APPLIES TO


 * Microsoft OLE DB Provider for Jet 4.0

-



This article was previously published under Q294164



SYMPTOMS
When you use the DBTIMESTAMP structure to update a Date/Time field in a Microsoft Access table, the fraction element of the structure may be truncated or ignored without warning or error.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
The Date/Time field is mapped to DBTYPE_DATE by design. However, when you use DBTIMESTAMP to obtain more information, the update operation completes successfully and returns S_OK status. This should return an error message, or at least a warning.

Steps to Reproduce Behavior
 Create an Access 2000 database named &quot;Test.mdb&quot; with a table named &quot;TestTable&quot;. Name one of the fields of this table &quot;date_time&quot; and make it type DATE/TIME.  Run the code below.NOTE: Modify the Path_to_your_database entry to reflect your database path when setting the DBPROP_INIT_DATASOURCE property in the code.
 * 1) define _ATL_STATIC_REGISTRY
 * 2) define _ATL_DEBUG_QI  // For debug output of ATL X COM.
 * 3) define _ATL_DEBUG_INTERFACES


 * 1) include 
 * 2) include 


 * 1) define RETURNHR(hr) if(FAILED((HRESULT)hr)) { AtlTraceErrorRecords((HRESULT)hr); return E_FAIL; }

// The user record looks like this. class CcmdTest { public: // Data elements. DBTIMESTAMP m_datetime; ULONG m_status;

BEGIN_COLUMN_MAP(CcmdTest) COLUMN_ENTRY_STATUS(1, m_datetime,m_status) END_COLUMN_MAP };

class CcmdTestRetrieval { public: // Data elements. DBTIMESTAMP m_datetime; ULONG m_status; BEGIN_COLUMN_MAP(CcmdTestRetrieval) COLUMN_ENTRY_STATUS(1,m_datetime,m_status) END_COLUMN_MAP // output binding map };

int main(void) {  HRESULT hr; CDataSource connection; CSession session; CCommand > cmdTest;           // Update the data. CCommand > cmdTest2; // Retrieve the data. // Connect the database, session, and accessors. CoInitialize(NULL); CDBPropSet dbinit(DBPROPSET_DBINIT); dbinit.AddProperty(DBPROP_AUTH_CACHE_AUTHINFO, true); dbinit.AddProperty(DBPROP_AUTH_ENCRYPT_PASSWORD, false); dbinit.AddProperty(DBPROP_AUTH_MASK_PASSWORD, false); dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR(&quot;&quot;)); dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR(&quot;Admin&quot;)); dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR(&quot;Path_to_your_database\\Test.mdb&quot;)); dbinit.AddProperty(DBPROP_INIT_MODE, (long)16); dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4); dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, OLESTR(&quot;&quot;)); dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033); dbinit.AddProperty(DBPROP_AUTH_CACHE_AUTHINFO, true); hr = connection.Open(_T(&quot;Microsoft.Jet.OLEDB.4.0&quot;), &dbinit); RETURNHR(hr); // Create the session. hr = session.Open(connection); RETURNHR(hr); // Get updatable rowset. CDBPropSet rsProps(DBPROPSET_ROWSET); rsProps.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE); rsProps.AddProperty(DBPROP_IRowsetChange, true); rsProps.AddProperty(DBPROP_IRowsetUpdate, true); rsProps.AddProperty(DBPROP_IRowsetScroll, true); hr = cmdTest.Open(session, &quot;Select date_time from TestTable2&quot;, &rsProps); RETURNHR(hr); hr = cmdTest.MoveFirst; RETURNHR(hr); // Set the structure to update the date/time field. DBTIMESTAMP tm;

tm.day     = 20; tm.fraction = 1000; tm.hour    = 2; tm.minute  = 20; tm.month   = 7; tm.second  = 30; tm.year    = 2000; cmdTest.m_datetime = tm; cmdTest.m_status = DBSTATUS_S_OK;

hr = cmdTest.SetData; hr = cmdTest.Update; cmdTest.Close; cmdTest.ReleaseCommand; // Retrieve the data. hr = cmdTest2.Open(session, &quot;Select date_time from TestTable&quot;); RETURNHR(hr); hr = cmdTest2.MoveFirst; RETURNHR(hr);

// Now check cmdTest2 in the watch window. // You will find the fraction element of m_datetime is set to 0.

cmdTest2.Close; cmdTest2.ReleaseCommand; session.Close; connection.Close;

return S_OK; }                   

Additional query words: jet fraction datetime DBTIMESTAMP

Keywords: kbbug kbnofix kbjet KB294164

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.