Results 1 to 3 of 3

Thread: datetime handling in VB.Net2005 and SQLserver2000

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    BC, Canada
    Posts
    142

    Resolved datetime handling in VB.Net2005 and SQLserver2000

    I am seeking a better way to handle DateTimePicker control as an
    optional field for users, a scenario is like this:

    • In a user interface I have a datetimepicker control for user to select
      a date as an option.
    • In Sql server 2000, I have a datetime field to hold its value or set to null
      if it has no value.
    • I have two stored procedures to handle saving into database and
      loading into my program with a datetime parameter as either a string
      or datetime.


    The way I am using in previous programs is like this:
    • In the database, set a datatime field with null as default value.
    • In stored procedure, the parameter for the datetime is set as a
      varchar(10) with default value of '', whenever the datetime is '' in the
      save procedure, it must be set a null value for the datetime field in
      the Database table in INsert or Update syntax.
    • In .Net program, the value in DateTimePicker must be converted to
      string when calling the stored procedure, If the datatime is not selected,
      its value is "". When loading the data from database, if datetime is null,
      it must be converted into a string "", then when loading ""
      into Datetimepicker , the control is unchecked to show no date was selected.


    Do you have a better way to handle this? like using System.Nullable class
    or using datetime datatype as parameter in SPs.

    Thanks. Your feedback is appreciated very much.
    Last edited by Winla; Feb 6th, 2007 at 05:44 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width