Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2007, 01:33 PM
Authorized User
 
Join Date: Oct 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default null date time

I'm having a problem. On my application I have several datetime textboxes that should be entered at certain times. If the datetime is not entered, it should enter either 'null' or it should remain empty in the database. Well if I don't enter anything in the textbox it throws an error saying "string does not recognize as valid datetime". Can someone help me so that error does not appear? Why won't it enter null and stay empty?

 
Old June 15th, 2007, 02:48 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Access delimits dates with #, so I used that as a sample
Code:
    If txtBx.Text = "" Then
        s = "NULL"
    Else
        s = " #" & txtBx.Text & "# "
    End If

    MyCnctn.Execute "UPDATE TheTable ( TheDateField ) " & _
                    "Values          ( " & s & "    ) ", , _
                    adCmdText
                    Just a simple sample to give you a possible solution approach.





Similar Threads
Thread Thread Starter Forum Replies Last Post
date and time in EST time zone anboss XSLT 1 May 21st, 2008 01:42 PM
I need to update a date value to null pannasn .NET Framework 2.0 0 December 11th, 2007 06:47 AM
setting date/time fields back to null value badgolfer Access 1 August 8th, 2005 02:29 AM
Null Value for Date/Time Field ksegars4 Crystal Reports 2 November 17th, 2004 11:58 AM
insert system date. no date and time jimmy Access VBA 6 November 20th, 2003 01:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.