smalldatetime Null in SQL for ASP.net Page

Discussion in 'ASP .Net' started by =?Utf-8?B?Um9iZXJ0IFdpbGxoaXRl?=, Oct 6, 2005.

  1. I have a database with a field used for an approval date set as a
    smalldatetime. When the record is initially written it is intended to be
    reviewd and approved. However until it is approved it has a null value,
    which throws an error in the ASP page that is intended to be used to review
    and update. The error is th DBNull to DateTime conversion error.

    Any Suggestions?
     
    =?Utf-8?B?Um9iZXJ0IFdpbGxoaXRl?=, Oct 6, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?Um9iZXJ0IFdpbGxoaXRl?=

    Patirck Ige Guest

    Show some snippets
    "Robert Willhite" <> wrote in
    message news:...
    > I have a database with a field used for an approval date set as a
    > smalldatetime. When the record is initially written it is intended to be
    > reviewd and approved. However until it is approved it has a null value,
    > which throws an error in the ASP page that is intended to be used to

    review
    > and update. The error is th DBNull to DateTime conversion error.
    >
    > Any Suggestions?
     
    Patirck Ige, Oct 6, 2005
    #2
    1. Advertising

  3. Patirck,

    Thanks for the quick response. I actually found the solution and will
    include it for any other searches

    My old code was:

    Request.ApprovedDate = drRequests.Item("ApprovedDate")

    I wrote new code as follows:

    If IsDBNull(drRequests.Item("ApprovedDate")) Then
    Request.ApprovedDate = " "
    Else
    Request.ApprovedDate = Format(drRequests.Item("ApprovedDate"), "d")
    End If


    Thanks,



    "Patirck Ige" wrote:

    > Show some snippets
    > "Robert Willhite" <> wrote in
    > message news:...
    > > I have a database with a field used for an approval date set as a
    > > smalldatetime. When the record is initially written it is intended to be
    > > reviewd and approved. However until it is approved it has a null value,
    > > which throws an error in the ASP page that is intended to be used to

    > review
    > > and update. The error is th DBNull to DateTime conversion error.
    > >
    > > Any Suggestions?

    >
    >
    >
     
    =?Utf-8?B?Um9iZXJ0IFdpbGxoaXRl?=, Oct 6, 2005
    #3
  4. =?Utf-8?B?Um9iZXJ0IFdpbGxoaXRl?=

    Patirck Ige Guest

    Good you got it working Robert
    Patrick

    "Robert Willhite" <> wrote in
    message news:...
    > Patirck,
    >
    > Thanks for the quick response. I actually found the solution and will
    > include it for any other searches
    >
    > My old code was:
    >
    > Request.ApprovedDate = drRequests.Item("ApprovedDate")
    >
    > I wrote new code as follows:
    >
    > If IsDBNull(drRequests.Item("ApprovedDate")) Then
    > Request.ApprovedDate = " "
    > Else
    > Request.ApprovedDate = Format(drRequests.Item("ApprovedDate"),

    "d")
    > End If
    >
    >
    > Thanks,
    >
    >
    >
    > "Patirck Ige" wrote:
    >
    > > Show some snippets
    > > "Robert Willhite" <> wrote in
    > > message news:...
    > > > I have a database with a field used for an approval date set as a
    > > > smalldatetime. When the record is initially written it is intended to

    be
    > > > reviewd and approved. However until it is approved it has a null

    value,
    > > > which throws an error in the ASP page that is intended to be used to

    > > review
    > > > and update. The error is th DBNull to DateTime conversion error.
    > > >
    > > > Any Suggestions?

    > >
    > >
    > >
     
    Patirck Ige, Oct 6, 2005
    #4
    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. Salim Afþar
    Replies:
    1
    Views:
    1,719
  2. Fred Nelson

    SmallDateTime and NULL Values

    Fred Nelson, Mar 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    560
    Natty Gur
    Mar 2, 2004
  3. Kivak Wolf
    Replies:
    2
    Views:
    10,118
    Kivak Wolf
    Jun 28, 2005
  4. Pat

    smalldatetime problem

    Pat, Aug 31, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,996
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=
    Sep 2, 2005
  5. .Net Sports

    Changing smalldatetime to string

    .Net Sports, Nov 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,705
    .Net Sports
    Nov 18, 2005
Loading...

Share This Page