473,414 Members | 1,590 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,414 software developers and data experts.

Revert Date back to NULL

BD
I have sent several posts on this topic and feel my lack of
information is not helping to find the solution. I am developing
application in C# with Visual Studio 2005 to connect with remote SQL
Server 2005. On one form, I have a textbox bound to a datetime column
on the server. When the form loads a new record, this textbox is
blank. This is correct. However, once a valid date has been entered
into this textbox, it cannot be removed and NULL inserted back into
the column. I know it is possible, I am presently using MS Access
2003 to connect to this same server and table and if I delete the
date, NULL is inserted back into the table and my textbox shows blank
or empty string. If access can do this, I know C# can as well.

Thank you for all assistance.

BD

Oct 30 '07 #1
3 1459
BD

Use Nullable DateTime (as long as you are in .Net 2.0 or better)

DateTime? foo = null;

if(foo.HasValue)
{
//Do work
}
Hope this helps.

David

"BD" wrote:
I have sent several posts on this topic and feel my lack of
information is not helping to find the solution. I am developing
application in C# with Visual Studio 2005 to connect with remote SQL
Server 2005. On one form, I have a textbox bound to a datetime column
on the server. When the form loads a new record, this textbox is
blank. This is correct. However, once a valid date has been entered
into this textbox, it cannot be removed and NULL inserted back into
the column. I know it is possible, I am presently using MS Access
2003 to connect to this same server and table and if I delete the
date, NULL is inserted back into the table and my textbox shows blank
or empty string. If access can do this, I know C# can as well.

Thank you for all assistance.

BD

Oct 30 '07 #2
BD
On Oct 30, 1:52 pm, D. Bows <DB...@discussions.microsoft.comwrote:
BD

Use Nullable DateTime (as long as you are in .Net 2.0 or better)

DateTime? foo = null;

if(foo.HasValue)
{
//Do work

}

Hope this helps.

David

"BD" wrote:
I have sent several posts on this topic and feel my lack of
information is not helping to find the solution. I am developing
application in C# with Visual Studio 2005 to connect with remote SQL
Server 2005. On one form, I have a textbox bound to a datetime column
on the server. When the form loads a new record, this textbox is
blank. This is correct. However, once a valid date has been entered
into this textbox, it cannot be removed and NULL inserted back into
the column. I know it is possible, I am presently using MS Access
2003 to connect to this same server and table and if I delete the
date, NULL is inserted back into the table and my textbox shows blank
or empty string. If access can do this, I know C# can as well.
Thank you for all assistance.
BD
I am using .NET 2.0. I can successfully check if the textbox has an
empty string, however, I cannot get NULL inserted back to the database.

Oct 30 '07 #3
On Oct 30, 1:30 pm, BD <bwald...@charter.netwrote:
I have sent several posts on this topic and feel my lack of
information is not helping to find the solution. I am developing
application in C# with Visual Studio 2005 to connect with remote SQL
Server 2005. On one form, I have a textbox bound to a datetime column
on the server. When the form loads a new record, this textbox is
blank. This is correct. However, once a valid date has been entered
into this textbox, it cannot be removed and NULL inserted back into
the column. I know it is possible, I am presently using MS Access
2003 to connect to this same server and table and if I delete the
date, NULL is inserted back into the table and my textbox shows blank
or empty string. If access can do this, I know C# can as well.

Thank you for all assistance.

BD
Once you've detected that the textbox is empty find the currently
bound datarow then call DataRow.SetNull(<column bound to textbox>).

Oct 30 '07 #4

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

Similar topics

5
by: Adrian Parker | last post by:
Hi. I have a date time picker in my program which uses ADO to read from an Access database. It works perfectly, unless the database is empty (no records) when opened. When you try to open an...
4
by: DCM Fan | last post by:
{CREATE TABLEs and INSERTs follow...} Gents, I have a main table that is in ONE-MANY with many other tables. For example, if the main table is named A, there are these realtionships: A-->B...
7
by: Thomas R. Hummel | last post by:
Hello all, I am trying to write a query that compares a member's enrollment period with the products that their group has had during that period (all members belong to a group and the products...
9
by: Thomas R. Hummel | last post by:
Hello, I am importing data that lists rates for particular coverages for a particular period of time. Unfortunately, the data source isn't very clean. I've come up with some rules that I think...
4
by: Joe User | last post by:
Hi all....I have a feeling this is going to be one of those twisted query questions, but here it goes anyways.... I want to generate a report that shows the chronology of events (represented by...
1
by: wiseleyb | last post by:
After doing a SetUIHandler how to I revert back to the default behavior? I'm using ICustomDoc cDoc = (ICustomDoc)this.wb.Document; cDoc.SetUIHandler((IDocHostUIHandler)this); to allow...
7
by: Bernard D | last post by:
Hi, I've just been asked to bring a couple of Access 97 apps up to date. The source files are 'difficult to locate' as they were done in 1999. I have the mde files, but Access says it can't...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
1
by: reubendb | last post by:
Hello, I have some function that output too much stuff to stderr when called, and I have no control over the function itself. So I thought as a workaround, I redirect stderr to /dev/null before...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
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,...
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
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
isladogs
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...
0
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...

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.