CRedordset::DoField Exschange error on CTime field 
Author Message
 CRedordset::DoField Exschange error on CTime field

 Hi there,

I have experienced this strange error. I have created a table in SQL
which is empty. The first field of this table is of type DATETIME. When
I create a CRecordset derived object for this table the C data type is
CTime for the member variable that corresponds to this field. The
strange thing is that when I call AddNew() and put values into the
variables and then call Update() the first line get inserted into the
empty table and then I get an unhandled exception .... Access violation
error. It relates to the following:

_AFX_INLINE int CTime::GetYear() const
        { return (GetLocalTm(NULL)->tm_year) + 1900; }

This occurs after the RFX_Date function according to the call stack.

RFX_Date(CFieldExchange * 0x0012f460, const char * 0x00417108 ??

1924 + 8 bytes

I do not get this error if there is a least one line in the table
before I start importing.

Any ideas?

Reagrds
Mark

--
========================================================================

May the force be with you - always.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 08 Dec 2002 03:00:00 GMT  
 CRedordset::DoField Exschange error on CTime field

Quote:

> Hi there,

>I have experienced this strange error. I have created a table in SQL
>which is empty. The first field of this table is of type DATETIME. When
>I create a CRecordset derived object for this table the C data type is
>CTime for the member variable that corresponds to this field. The
>strange thing is that when I call AddNew() and put values into the
>variables and then call Update() the first line get inserted into the
>empty table and then I get an unhandled exception .... Access violation
>error.

Note that CTime will only handle dates from (I think) 1980 to 2036.

I ended up writing my own date class, which was really a wrapper for a
TIMESTAMP_STRUCT

HTH

Paul
-------------------------------------------
Expressed opinions are usually my own.
Especially if they're any good (of course).
-------------------------------------------



Sun, 08 Dec 2002 03:00:00 GMT  
 CRedordset::DoField Exschange error on CTime field
I had the same problem last year and eventually put a dummy first line in my
database to just get around it.

But I may have run into a clue, recently.  If you create a Date parameter
and then don't use it, you get the same error.  If you set the date
parameter to a valid date, even if you don't use it, you don't get the
error.  I haven't tried it, but perhaps if you set the initialize the Date
fields in your recordset to a valid date...  Good luck and if it works, let
us know!

Steve

Quote:

>  Hi there,

> I have experienced this strange error. I have created a table in SQL
> which is empty. The first field of this table is of type DATETIME. When
> I create a CRecordset derived object for this table the C data type is
> CTime for the member variable that corresponds to this field. The
> strange thing is that when I call AddNew() and put values into the
> variables and then call Update() the first line get inserted into the
> empty table and then I get an unhandled exception .... Access violation
> error. It relates to the following:

> _AFX_INLINE int CTime::GetYear() const
>         { return (GetLocalTm(NULL)->tm_year) + 1900; }

> This occurs after the RFX_Date function according to the call stack.

> RFX_Date(CFieldExchange * 0x0012f460, const char * 0x00417108 ??

> 1924 + 8 bytes

> I do not get this error if there is a least one line in the table
> before I start importing.

> Any ideas?

> Reagrds
> Mark

> --
> ========================================================================

> May the force be with you - always.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 08 Dec 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help, SDI program problems with CTime Fields

2. ODBC and CTime fields

3. Data truncated in credordset

4. Linker Error on asctime, ctime, localtime functions...

5. error LNK2001: using CTime.Format

6. Error on CTime (y2k)

7. CTime error?!

8. CResultSet and CTime error !

9. Flags, Bitwise Bit Field, Enumeration, Error C2440

10. making bit field with union: error zero length?

11. Recordset::Close after Field::PutValue --> ERROR

12. GetSQLDefault -- ambiguous field runtime error

 

 
Powered by phpBB® Forum Software