Datetime field in SQLserver database empty?

Discussion in 'ASP .Net' started by Thierry, Jan 15, 2004.

  1. Thierry

    Thierry Guest

    Hi,



    I've got the next problem: I have a datetime field in my database
    (sql-server) and I want the option in it that this field can be empty. But
    if I leave that datetime field empty I get the error:

    "The value you entered is not consistent with the data type or length of the
    column."



    Is it possible to leave that field empty and how is it possible? If not what
    do I have to do to leave it empty, because in my application this (date) is
    not a required field?



    Thanks for your help,

    Thierry
     
    Thierry, Jan 15, 2004
    #1
    1. Advertising

  2. Thierry

    Michael Guest

    If someone else knows a better way I'm all ears,

    The only way I know how to have a truly empty date is to allow nulls in the
    datetime field. Then in code, you can set the variable you are updating
    with to System.DBnull.Value. Or if you are working off typed datasets, you
    can use myDataSet.myTable(rowNum).setField_NameNull(), at least something
    like that I'm not sure if that syntax is correct.

    --Michael
    "Thierry" <> wrote in message
    news:rXxNb.13125$-ops.be...
    > Hi,
    >
    >
    >
    > I've got the next problem: I have a datetime field in my database
    > (sql-server) and I want the option in it that this field can be empty. But
    > if I leave that datetime field empty I get the error:
    >
    > "The value you entered is not consistent with the data type or length of

    the
    > column."
    >
    >
    >
    > Is it possible to leave that field empty and how is it possible? If not

    what
    > do I have to do to leave it empty, because in my application this (date)

    is
    > not a required field?
    >
    >
    >
    > Thanks for your help,
    >
    > Thierry
    >
    >
     
    Michael, Jan 15, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    734
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    556
    Tim Peters
    Sep 9, 2003
  3. mp
    Replies:
    1
    Views:
    403
    John Machin
    Jul 28, 2006
  4. Martin
    Replies:
    0
    Views:
    350
    Martin
    Dec 27, 2008
  5. Replies:
    2
    Views:
    776
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page