
ADO, "0001-01-01" Date value causes error 80040e21 when reading
I can open the recordset, I can read everything else including this
column for other records where the date is a modern date. Any date
field below a certain value (I haven't bothered to find out what this
value is) seems to have this problem. I have checked the type of Field
and it comes back as type "adDBDate".
Here is an extract of the code. I am trying to copy the recordset to a
temporary recordset. I have checked and it is not a problem with
adoTempRec because I still get the error when I do a "debug.print
adoRec(i)"
Here is the connection string:
Public Const adoConnStr As String = "Provider=MSDASQL.1;Extended
Properties=""DRIVER=Teradata;DBCNAME=pcop1;UID=;PWD=;DATABASE="""
And the part of the code that has the error:
Set adoRec = New ADODB.Recordset
blnExecuteComplete = False
adoRec.Open sqlExec, adoConn, , , adAsyncExecute
While Not blnExecuteComplete
DoEvents
Wend
If blnSQLError Then
Exit For
End If
Set adoTempRec = CopyRecordSet(adoRec)
While Not adoRec.EOF And Not frmStatus.blnCancel
adoTempRec.AddNew
For i = 0 To adoRec.Fields.Count - 1
adoTempRec(i) = adoRec(i)
Next i
adoTempRec.Update
adoRec.MoveNext
DoEvents
Wend
adoRec.Close
Set adoRec = Nothing
Set adoRec = adoTempRec
Thanks to anyone who can help
Jason
Quote:
> Hi,
> Can you open recordset or you even cannot do that? Could
> you please post your code which reads value from that
> field?
> Thanks,
> Val
> >-----Original Message-----
> >I have an ADO application accessing a Teradata Database.
> I am
> >connecting using ADO2.6 using the Microsoft OLE DB
> Provider for ODBC
> >Drivers. It is quite common and valid to have date values
> in our
> >database with the value "0001-01-01". Whenever I try to
> read a field
> >with this date value in it I get the run time error:
> >80040e21 Multiple-step OLE DB operation generated errors.
> Check each
> >OLE DB status value, if available. No work was done.
> >I done extensive searching of newsgroups, the msdn site
> and the rest
> >of the web trying to find a solution to this problem. I
> have found
> >many sites offering help for this particular error
> message but none of
> >them are helpful for my particular problem. I am guessing
> that this
> >error is caused because Microsoft didn't cater for dates
> this low.
> >What I am asking is, Is there a work around for this
> problem? eg. can
> >I tell ado to treat all dates as Chars or something
> similar.
> >.