About Insert Null to DateTime Field

Discussion in 'ASP .Net' started by FatboyCanteen, Nov 11, 2003.

  1. When I using dataset to append
    a null value to the datetime field.

    It throw a error -> can not convert db.null to system.date

    Can there is any standard to pass a Null value
    to the DateTime Field!
    (It is successful to pass the Null Value to other type of
    Field)
     
    FatboyCanteen, Nov 11, 2003
    #1
    1. Advertising

  2. You can pass nulls to other types, but not to a system.datetime. I instead
    set it to system.datetime.minvalue and then test for that in my code as if
    it was a null.

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - FrontPage

    "FatboyCanteen" <> wrote in message
    news:063001c3a7f2$b75c0050$...
    > When I using dataset to append
    > a null value to the datetime field.
    >
    > It throw a error -> can not convert db.null to system.date
    >
    > Can there is any standard to pass a Null value
    > to the DateTime Field!
    > (It is successful to pass the Null Value to other type of
    > Field)
     
    Mark Fitzpatrick, Nov 11, 2003
    #2
    1. Advertising

  3. Thank You for your reply!
    Yes, I am using your method in the past (but using max
    value)
    However, I want to know anyone can successful insert a
    null value to DateTime Field.



    >-----Original Message-----
    >You can pass nulls to other types, but not to a

    system.datetime. I instead
    >set it to system.datetime.minvalue and then test for

    that in my code as if
    >it was a null.
    >
    > Hope this helps,
    > Mark Fitzpatrick
    > Microsoft MVP - FrontPage
    >
    >"FatboyCanteen" <> wrote in

    message
    >news:063001c3a7f2$b75c0050$...
    >> When I using dataset to append
    >> a null value to the datetime field.
    >>
    >> It throw a error -> can not convert db.null to

    system.date
    >>
    >> Can there is any standard to pass a Null value
    >> to the DateTime Field!
    >> (It is successful to pass the Null Value to other type

    of
    >> Field)

    >
    >
    >.
    >
     
    FatboyCanteen, Nov 11, 2003
    #3
  4. Take a look @ http://www.c-sharpcorner.com/Code/2003/Sept/EnterNullValuesForDateTime.asp

    HTH
    -Sushila

    "FatboyCanteen" <> wrote in message news:076f01c3a7f7$2873bc20$...
    > Thank You for your reply!
    > Yes, I am using your method in the past (but using max
    > value)
    > However, I want to know anyone can successful insert a
    > null value to DateTime Field.
    >
    >
    >
    > >-----Original Message-----
    > >You can pass nulls to other types, but not to a

    > system.datetime. I instead
    > >set it to system.datetime.minvalue and then test for

    > that in my code as if
    > >it was a null.
    > >
    > > Hope this helps,
    > > Mark Fitzpatrick
    > > Microsoft MVP - FrontPage
    > >
    > >"FatboyCanteen" <> wrote in

    > message
    > >news:063001c3a7f2$b75c0050$...
    > >> When I using dataset to append
    > >> a null value to the datetime field.
    > >>
    > >> It throw a error -> can not convert db.null to

    > system.date
    > >>
    > >> Can there is any standard to pass a Null value
    > >> to the DateTime Field!
    > >> (It is successful to pass the Null Value to other type

    > of
    > >> Field)

    > >
    > >
    > >.
    > >
     
    Sonali.NET[MVP], Nov 11, 2003
    #4
  5. i use the following to insert NULL into datetime field and it works

    Object.DateTimeField = DBNull.Value;

    ofcourse the field should be able to accept null values...

    -PK

    "FatboyCanteen" <> wrote in message
    news:063001c3a7f2$b75c0050$...
    > When I using dataset to append
    > a null value to the datetime field.
    >
    > It throw a error -> can not convert db.null to system.date
    >
    > Can there is any standard to pass a Null value
    > to the DateTime Field!
    > (It is successful to pass the Null Value to other type of
    > Field)
     
    Prashant Kondle, Nov 11, 2003
    #5
  6. Can you explain more detail about insert null value
    Because I don't understand --
    object.DateTimeField

    Thank YOu

    >-----Original Message-----
    >i use the following to insert NULL into datetime field

    and it works
    >
    >Object.DateTimeField = DBNull.Value;
    >
    >ofcourse the field should be able to accept null

    values...
    >
    >-PK
    >
    >"FatboyCanteen" <> wrote in

    message
    >news:063001c3a7f2$b75c0050$...
    >> When I using dataset to append
    >> a null value to the datetime field.
    >>
    >> It throw a error -> can not convert db.null to

    system.date
    >>
    >> Can there is any standard to pass a Null value
    >> to the DateTime Field!
    >> (It is successful to pass the Null Value to other type

    of
    >> Field)

    >
    >
    >.
    >
     
    FatboyCanteen, Nov 11, 2003
    #6
  7. if ur using NullDate as the field containing the value to insert into the
    DateTime field then
    do
    NullDate = DBNull.Value;

    -PK



    "FatboyCanteen" <> wrote in message
    news:08db01c3a815$553da9f0$...
    > Can you explain more detail about insert null value
    > Because I don't understand --
    > object.DateTimeField
    >
    > Thank YOu
    >
    > >-----Original Message-----
    > >i use the following to insert NULL into datetime field

    > and it works
    > >
    > >Object.DateTimeField = DBNull.Value;
    > >
    > >ofcourse the field should be able to accept null

    > values...
    > >
    > >-PK
    > >
    > >"FatboyCanteen" <> wrote in

    > message
    > >news:063001c3a7f2$b75c0050$...
    > >> When I using dataset to append
    > >> a null value to the datetime field.
    > >>
    > >> It throw a error -> can not convert db.null to

    > system.date
    > >>
    > >> Can there is any standard to pass a Null value
    > >> to the DateTime Field!
    > >> (It is successful to pass the Null Value to other type

    > of
    > >> Field)

    > >
    > >
    > >.
    > >
     
    Prashant Kondle, Nov 11, 2003
    #7
    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:
    732
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    555
    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:
    775
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page