473,387 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DateTime problem

Hi all,

in a huge project i have the following problem.
I create an object which contains many private members (i know that this is
not correct, but it is a single use migration program). The members will be
filled from database tables. In the fill method i see in debug mode the
correct values. At the source where i create the object the DateTime members
of the object are not present (error: cannot obtain value). An statement like
this
DateTime dat = object.startDate delivers 01/01/01.
If the object reference will be pass to a other method, inthis method is the
correct value present.
This all happens only for the DateTime members. Int32, Strinng are not
affected.

Who can help?

Josef Fieseler
Aug 11 '06 #1
6 1830
Correction: I mind certainly "public members"

"JFieseler" wrote:
Hi all,

in a huge project i have the following problem.
I create an object which contains many private members (i know that this is
not correct, but it is a single use migration program). The members will be
filled from database tables. In the fill method i see in debug mode the
correct values. At the source where i create the object the DateTime members
of the object are not present (error: cannot obtain value). An statement like
this
DateTime dat = object.startDate delivers 01/01/01.
If the object reference will be pass to a other method, inthis method is the
correct value present.
This all happens only for the DateTime members. Int32, Strinng are not
affected.

Who can help?

Josef Fieseler
Aug 11 '06 #2
Hi Josef,

I'm not sure I follow you

I assume you have a startDate member in your object, but I'm not sure what
happens to this member. Is it set to null, DateTime.Minimum or some other
value to begin with?

When does object.startDate return 01/01/01?

I suspect you are trying to use an uninitizalied DateTime object, although
I may have misunderstood your letter.
Remember also that the debugger may not always show the correct
information.

On Fri, 11 Aug 2006 11:48:01 +0200, JFieseler
<JF*******@discussions.microsoft.comwrote:
Correction: I mind certainly "public members"

"JFieseler" wrote:
>Hi all,

in a huge project i have the following problem.
I create an object which contains many private members (i know that
this is
not correct, but it is a single use migration program). The members
will be
filled from database tables. In the fill method i see in debug mode the
correct values. At the source where i create the object the DateTime
members
of the object are not present (error: cannot obtain value). An
statement like
this
DateTime dat = object.startDate delivers 01/01/01.
If the object reference will be pass to a other method, inthis method
is the
correct value present.
This all happens only for the DateTime members. Int32, Strinng are not
affected.

Who can help?

Josef Fieseler


--
Happy Coding!
Morten Wennevik [C# MVP]
Aug 11 '06 #3
Hi Morten,

i will try to clarify my problem:

class X {public DateTime dat; ... public void LoadFromDB() }

Main:
X x = new x();
x.LoadFromDB; // If i debug the LoadFromDB method i see the correct date
value.
DateTime myDat = x.dat // Result = 01/01/01
AnyMethod(x)
public void AnyMethod(X x)
{
x.dat has the correct value!!!!!!!
}
Best regards
Joe
"Morten Wennevik" wrote:
Hi Josef,

I'm not sure I follow you

I assume you have a startDate member in your object, but I'm not sure what
happens to this member. Is it set to null, DateTime.Minimum or some other
value to begin with?

When does object.startDate return 01/01/01?

I suspect you are trying to use an uninitizalied DateTime object, although
I may have misunderstood your letter.
Remember also that the debugger may not always show the correct
information.

On Fri, 11 Aug 2006 11:48:01 +0200, JFieseler
<JF*******@discussions.microsoft.comwrote:
Correction: I mind certainly "public members"

"JFieseler" wrote:
Hi all,

in a huge project i have the following problem.
I create an object which contains many private members (i know that
this is
not correct, but it is a single use migration program). The members
will be
filled from database tables. In the fill method i see in debug mode the
correct values. At the source where i create the object the DateTime
members
of the object are not present (error: cannot obtain value). An
statement like
this
DateTime dat = object.startDate delivers 01/01/01.
If the object reference will be pass to a other method, inthis method
is the
correct value present.
This all happens only for the DateTime members. Int32, Strinng are not
affected.

Who can help?

Josef Fieseler

--
Happy Coding!
Morten Wennevik [C# MVP]
Aug 11 '06 #4
Hm are you saying that myDat ends up 01/01/01 even if x.dat is correct?
Or do you mean x.dat is wrong when you call x.dat the first time, but
correct when you call it from AnyMethod? I assume 01/01/01 is not the
correct value.

I can't tell from your pseudocode what is wrong. It would help if you
could show us some real code.

dat will be 01/01/01 since a class variable of type DateTime will be
initialized to DateTime.Minimum.
It will remain DateTime.Minimum until changed. If you read from the
database, but dat is unchanged I'd check how you store the database value
into dat.
On Fri, 11 Aug 2006 12:42:02 +0200, JFieseler
<JF*******@discussions.microsoft.comwrote:
Hi Morten,

i will try to clarify my problem:

class X {public DateTime dat; ... public void LoadFromDB() }

Main:
X x = new x();
x.LoadFromDB; // If i debug the LoadFromDB method i see the correct date
value.
DateTime myDat = x.dat // Result = 01/01/01
AnyMethod(x)
public void AnyMethod(X x)
{
x.dat has the correct value!!!!!!!
}
Best regards
Joe
"Morten Wennevik" wrote:
>Hi Josef,

I'm not sure I follow you

I assume you have a startDate member in your object, but I'm not sure
what
happens to this member. Is it set to null, DateTime.Minimum or some
other
value to begin with?

When does object.startDate return 01/01/01?

I suspect you are trying to use an uninitizalied DateTime object,
although
I may have misunderstood your letter.
Remember also that the debugger may not always show the correct
information.

On Fri, 11 Aug 2006 11:48:01 +0200, JFieseler
<JF*******@discussions.microsoft.comwrote:
Correction: I mind certainly "public members"

"JFieseler" wrote:

Hi all,

in a huge project i have the following problem.
I create an object which contains many private members (i know that
this is
not correct, but it is a single use migration program). The members
will be
filled from database tables. In the fill method i see in debug mode
the
>correct values. At the source where i create the object the DateTime
members
of the object are not present (error: cannot obtain value). An
statement like
this
DateTime dat = object.startDate delivers 01/01/01.
If the object reference will be pass to a other method, inthis method
is the
correct value present.
This all happens only for the DateTime members. Int32, Strinng are
not
>affected.

Who can help?

Josef Fieseler

--
Happy Coding!
Morten Wennevik [C# MVP]


--
Happy Coding!
Morten Wennevik [C# MVP]
Aug 11 '06 #5
Yes, x.dat is correct (debugging the Load-Method) and myDat not! If i debug
the
Statement "DateTime myDat = x.dat" the value of x.dat.Year is: "error:
cannot obtain value"

"JFieseler" wrote:
Correction: I mind certainly "public members"

"JFieseler" wrote:
Hi all,

in a huge project i have the following problem.
I create an object which contains many private members (i know that this is
not correct, but it is a single use migration program). The members will be
filled from database tables. In the fill method i see in debug mode the
correct values. At the source where i create the object the DateTime members
of the object are not present (error: cannot obtain value). An statement like
this
DateTime dat = object.startDate delivers 01/01/01.
If the object reference will be pass to a other method, inthis method is the
correct value present.
This all happens only for the DateTime members. Int32, Strinng are not
affected.

Who can help?

Josef Fieseler
Aug 11 '06 #6
Hi Morton,

i have found the solution per luck:

After the statement
DateTime myDat = x.dat
follows many Method Calls with many params. Nearly all params are self
defined objects.
I have change all params from "by value" to "by reference" and behold it
works correctly!
Many thanks for this chat.
Joe

"Morten Wennevik" wrote:
Hm are you saying that myDat ends up 01/01/01 even if x.dat is correct?
Or do you mean x.dat is wrong when you call x.dat the first time, but
correct when you call it from AnyMethod? I assume 01/01/01 is not the
correct value.

I can't tell from your pseudocode what is wrong. It would help if you
could show us some real code.

dat will be 01/01/01 since a class variable of type DateTime will be
initialized to DateTime.Minimum.
It will remain DateTime.Minimum until changed. If you read from the
database, but dat is unchanged I'd check how you store the database value
into dat.
On Fri, 11 Aug 2006 12:42:02 +0200, JFieseler
<JF*******@discussions.microsoft.comwrote:
Hi Morten,

i will try to clarify my problem:

class X {public DateTime dat; ... public void LoadFromDB() }

Main:
X x = new x();
x.LoadFromDB; // If i debug the LoadFromDB method i see the correct date
value.
DateTime myDat = x.dat // Result = 01/01/01
AnyMethod(x)
public void AnyMethod(X x)
{
x.dat has the correct value!!!!!!!
}
Best regards
Joe
"Morten Wennevik" wrote:
Hi Josef,

I'm not sure I follow you

I assume you have a startDate member in your object, but I'm not sure
what
happens to this member. Is it set to null, DateTime.Minimum or some
other
value to begin with?

When does object.startDate return 01/01/01?

I suspect you are trying to use an uninitizalied DateTime object,
although
I may have misunderstood your letter.
Remember also that the debugger may not always show the correct
information.

On Fri, 11 Aug 2006 11:48:01 +0200, JFieseler
<JF*******@discussions.microsoft.comwrote:

Correction: I mind certainly "public members"

"JFieseler" wrote:

Hi all,

in a huge project i have the following problem.
I create an object which contains many private members (i know that
this is
not correct, but it is a single use migration program). The members
will be
filled from database tables. In the fill method i see in debug mode
the
correct values. At the source where i create the object the DateTime
members
of the object are not present (error: cannot obtain value). An
statement like
this
DateTime dat = object.startDate delivers 01/01/01.
If the object reference will be pass to a other method, inthis method
is the
correct value present.
This all happens only for the DateTime members. Int32, Strinng are
not
affected.

Who can help?

Josef Fieseler

--
Happy Coding!
Morten Wennevik [C# MVP]

--
Happy Coding!
Morten Wennevik [C# MVP]
Aug 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mingus Tsai | last post by:
Hello- please help with unpickling problem: I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows XPhome system. My problem is with using cPickle to deserialize my pickled...
2
by: Rey | last post by:
Howdy all. My problem deals w/inserting nulls into database (SQL Svr 2K) for the datetime fields activityDate and followUpDate where nulls are allowed. >From the web form, the user can type...
8
by: Alan Silver | last post by:
Hello, I have a custom control that displays the date and time. I currently have properties for the day, month, year, hour and minute, which have to be set separately. This is inefficient. I...
5
by: I am Sam | last post by:
I have created this DateTime object and instanced it I think correctly DateTime myClubNow1=new...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
3
by: pranesh.nayak | last post by:
I'm facing an error:"String was not recognized as a valid DateTime" whille accessing DateTime from webservice. And when I try to set DateTime to the same webservice it fails with error:"Date...
5
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
4
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I am having a problem formatting a string when the time is in format hh.mm.ss - used in Europe Parse seems ok when the date uses "/" or "." as seperator but I get an exception when time...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.