hey,
I always struggle with the following:
I have an object obj with a property paydate (type = DateTime)
Now, after instantiating the object and do several things, I want too check if my paydate is still empty.
How can I do this?
I tried several things like (all with errors):
if (obj.paydate == null)
if (obj.paydate.ge ttype() == System.DBnull)
if (obj.paydate == 01/01/0001)
etc.....
Another question :
When I want to instantiate the object and fill it with data from an sql-query (sql-database). The value received from sql for paydate = null.
How can I test in the datareader that the received data from sql is null and so I put nothing in obj.paydate.
tkx,
Nic 2 3851
nic <ni*@discussion s.microsoft.com > wrote: I always struggle with the following:
I have an object obj with a property paydate (type = DateTime) Now, after instantiating the object and do several things, I want too check if my paydate is still empty.
It's not empty to start with. There's no equivalent for null for value
types. Some people choose to use DateTime.MinVal ue as a "special" value
equivalent to null for DateTimes. Others use a separate property to
indicate whether or not the DateTime is a "real" one.
Another question : When I want to instantiate the object and fill it with data from an sql-query (sql-database). The value received from sql for paydate = null. How can I test in the datareader that the received data from sql is null and so I put nothing in obj.paydate.
Use the IsDbNull() in the DataReader. You'll still have to work out
what to put into paydate in that case though.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi,
If you initalize the paydate as PayDate = new DateTime() in the class
constructor, you can compare paydate with DateTime.MinVal ue to check if it
still has the initial value. The only problem with this is that if the user
sets paydate to 01/01/0001 00:00:00, then you wont be able to detect the
changes as DateTime.MinVal ue is nothing but 01/01/0001 00:00:00.
Alternatively, you can maintain your own dirty flag in the set accessor
method of the paydate and check that flag to detect any changes.
For checking null, use SqlDataReader.I sDBNull()
HTH.
"nic" <ni*@discussion s.microsoft.com > wrote in message
news:95******** *************** ***********@mic rosoft.com...
hey,
I always struggle with the following:
I have an object obj with a property paydate (type = DateTime)
Now, after instantiating the object and do several things, I want too check
if my paydate is still empty.
How can I do this?
I tried several things like (all with errors):
if (obj.paydate == null)
if (obj.paydate.ge ttype() == System.DBnull)
if (obj.paydate == 01/01/0001)
etc.....
Another question :
When I want to instantiate the object and fill it with data from an
sql-query (sql-database). The value received from sql for paydate = null.
How can I test in the datareader that the received data from sql is null and
so I put nothing in obj.paydate.
tkx,
Nic This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ramarnath |
last post by:
Problem in sending datatime format to the .net webservice from php.
description follows.
I've created a .net webservice.
..Net Webservice:
<WebMethod()> _
Public Function HelloDate(ByVal mydate As DateTime) As String
|
by: niju |
last post by:
Hi there
I am trying to get a single digit hour in 12-hour format with the
following code.
DateTime hr = DateTime.Now;
string hour = hr.ToString("h");
However, I get "Input string was not in a correct format" error. Please
help me to correct this problem.
|
by: Lee |
last post by:
Hello all,
I'm trying to solve a problem with a string to datetime conversion.
The problem arises when I try to convert a string from an XML doc into
a .net DateTime. I'm manually creating a dataset from scratch and
adding the fields and their DataTypes, appending to new datatable, etc.
I've googled extensively until the wee hours of the morning and just
can't seem to get this to work.
|
by: luckyabhishek |
last post by:
Hi
I am using a java webservice in a .NET application. The xml type of a
field in this webservice is xsd:datetime. When i call the webservice
from the application i get a deserialization error on the java
webservice side. It says "Can not create instance of
from string with schema type
http://www.w3.org/2001/XMLSchema]". Can anyone let me know
what could be the problem.
I am just sending a DateTime object which i get from a VB...
|
by: JFieseler |
last post by:
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...
| |
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 (MSSQL Server)
it worked on my test machine. If I run the same application on another
machine with different regional settings is not working. I tried with
date_default_timezone_set to change timezone but is not changing. After...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |