Microsoft KB Archive/274506

= FIX: When You Set a Date Field to Empty an Error Message Occurs =

Article ID: 274506

Article Last Modified on 5/17/2007

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.5
 * Microsoft Data Access Components 2.1
 * Microsoft Data Access Components 2.5

-



This article was previously published under Q274506



SYMPTOMS
When you attempt to store the Microsoft Visual Basic keyword EMPTY to an ADODB Record column based on a Date field, the following error message occurs:

With MDAC 2.5:

Run-time error '-2147217887(8004e21)': Multiple-step operation generated errors. Check each status value.

With MDAC 2.1.4202.3:

Run-time error '-2147217887(8004e21)': Errors Occurred

This behavior does not occur if the Native Jet Provider is used against a Microsoft Access 2000 or Microsoft Access 97 database.



CAUSE
There was no conversion information for converting between Empty and DBTimeStamp in the products listed in the &quot;Applies to&quot; section.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem has been fixed in Microsoft ActiveX Data Objects versions 2.6 and later. You can install the latest version of Microsoft Data Access Components from the following Web site:

http://msdn2.microsoft.com/en-us/data/aa937695.aspx



MORE INFORMATION
This error message occurs when you use the Native OLE DB Provider for SQL Server, the Native OLE DB Provider for Oracle, or OLE DB Provider for ODBC.

Steps to Reproduce Behavior
 Start Visual Basic. Set a Project reference to Microsoft Data Objects 2.5 Library.  Paste the following code into the Form_Load event: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset

cn.Open &quot;Provider=SQLOLEDB.1;User ID= ;Password= ;Initial Catalog=pubs;Data Source=&quot; 'cn.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source= ;&quot; 'cn.Open &quot;Provider=MSDASQL;DRIVER={sql server};SERVER=;UID= ;PASSWORD= ;DATABASE=pubs;&quot; 'cn.Open &quot;Provider=MSDAORA.1;User ID= ;PASSWORD= ;Data Source=;&quot;

cn.CursorLocation = adUseClient On Error Resume Next cn.Execute &quot;drop table batchtest&quot; On Error GoTo 0

'If testing with Jet or SQL cn.Execute &quot;create table batchtest (id int primary key,&quot; & _            &quot;fstring varchar(50) NOT NULL,&quot; & _             &quot;fnumber int NOT NULL,&quot; & _             &quot;fdate datetime NOT NULL)&quot; 'If testing with Oracle 'cn.Execute &quot;create table batchtest (id int primary key,&quot; & _            &quot;fstring varchar(50) NOT NULL,&quot; & _             &quot;fnumber int NOT NULL,&quot; & _             &quot;fdate date NOT NULL)&quot; rs.Open &quot;select * from batchtest&quot;, cn, adOpenStatic, adLockBatchOptimistic

rs.AddNew rs.Fields(&quot;id&quot;).Value = 1 rs.Fields(&quot;fstring&quot;).Value = &quot;XXXXX&quot; rs.Fields(&quot;fnumber&quot;).Value = 999 rs.Fields(&quot;fdate&quot;).Value = #3/3/1999# rs.Update rs.AddNew rs.Update rs.AddNew rs.Fields(&quot;id&quot;).Value = 2 rs.Fields(&quot;fstring&quot;).Value = Empty rs.Fields(&quot;fnumber&quot;).Value = Empty rs.Fields(&quot;fdate&quot;).Value = Empty 'Error occurs here. rs.Update cn.Close Set cn = Nothing  Uncomment the cn.Open statement that matches the backend database that is being tested. Make the appropriate changes and supply valid connection parameters.</li> Save and then run the Project. The error message shown in the &quot;Symptoms&quot; section occurs.</li></ol>

Additional query words: empty date time -2147217887 8004e21 null error

Keywords: kbbug kbfix kbmdac260fix KB274506

-

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

© Microsoft Corporation. All rights reserved.