Design issue: Handling null datetimes from legacy databases. - DOTNET

This is a discussion on Design issue: Handling null datetimes from legacy databases. - DOTNET ; I'm writing a demo website in VB /Dot Net 2.0. The database is SQL 2000 and the design is at least partially legacy. (And this is the first real web work I've done in 2.0. All previous work was in ...

+ Reply to Thread
Results 1 to 4 of 4

Design issue: Handling null datetimes from legacy databases.

  1. Default Design issue: Handling null datetimes from legacy databases.

    I'm writing a demo website in VB/Dot Net 2.0. The database is SQL 2000 and
    the design is at least partially legacy. (And this is the first real web
    work I've done in 2.0. All previous work was in 1.1) It is my intent to
    stay as close to defaults as possible: i.e. using the most generic techniques
    possible with as little coding as possible.

    My existing database table has some datetime field values that are null. I
    have a page with a detailsview bound to a record in that table. The
    datetime fields on my webpage are templates. The read-only screen has no
    problem displaying the record, but when I hit the Edit link, the page crashes
    with the message: 'Conversion from type 'DBNull' to type 'Date' is not
    valid.' So far I have not been able to intercept this in VB code.

    Apparently it is useless to set the field's xsd default property to
    something like '1/1/1900' or '1/1/1753'. I still get the crash. Also I
    cannot set the NullValue property to anything other than (Throw Exception)
    when the field is a datetime.

    I'm getting the impression from my reading that the best approach is to not
    permit null datetimes in the first place and that I should simply revise the
    database table.

    Suggestions?

  2. Default Re: Design issue: Handling null datetimes from legacy databases.

    http://www.google.com/search?hl=en&q...+nullable+C%23

    http://www.c-sharpcorner.com/UploadF...abletypes.aspx


    You can google search "nullable datetime" and find some stuff.

    The second URL above is one I picked.


    Luckily, you are at using (at least) 2.0.



    .........




    "B. Chernick" <BChernick@discussions.microsoft.com> wrote in message
    news:18012C94-C53D-49BB-BE29-BDA5A4278EEA@microsoft.com...
    > I'm writing a demo website in VB/Dot Net 2.0. The database is SQL 2000
    > and
    > the design is at least partially legacy. (And this is the first real web
    > work I've done in 2.0. All previous work was in 1.1) It is my intent to
    > stay as close to defaults as possible: i.e. using the most generic
    > techniques
    > possible with as little coding as possible.
    >
    > My existing database table has some datetime field values that are null.
    > I
    > have a page with a detailsview bound to a record in that table. The
    > datetime fields on my webpage are templates. The read-only screen has no
    > problem displaying the record, but when I hit the Edit link, the page
    > crashes
    > with the message: 'Conversion from type 'DBNull' to type 'Date' is not
    > valid.' So far I have not been able to intercept this in VB code.
    >
    > Apparently it is useless to set the field's xsd default property to
    > something like '1/1/1900' or '1/1/1753'. I still get the crash. Also I
    > cannot set the NullValue property to anything other than (Throw Exception)
    > when the field is a datetime.
    >
    > I'm getting the impression from my reading that the best approach is to
    > not
    > permit null datetimes in the first place and that I should simply revise
    > the
    > database table.
    >
    > Suggestions?




  3. Default Re: Design issue: Handling null datetimes from legacy databases.

    Thanks but so far I don't get it. I simply dragged a table onto the xsd and
    bound it to a detailsview with almost no coding. Is this type of code (the
    c-sharpcorner example) supposed to be put in the xsd's code behind? The xsd
    itself can't handle nullable declarations.

    "sloan" wrote:

    > http://www.google.com/search?hl=en&q...+nullable+C%23
    >
    > http://www.c-sharpcorner.com/UploadF...abletypes.aspx
    >
    >
    > You can google search "nullable datetime" and find some stuff.
    >
    > The second URL above is one I picked.
    >
    >
    > Luckily, you are at using (at least) 2.0.
    >
    >
    >
    > .........
    >
    >
    >
    >
    > "B. Chernick" <BChernick@discussions.microsoft.com> wrote in message
    > news:18012C94-C53D-49BB-BE29-BDA5A4278EEA@microsoft.com...
    > > I'm writing a demo website in VB/Dot Net 2.0. The database is SQL 2000
    > > and
    > > the design is at least partially legacy. (And this is the first real web
    > > work I've done in 2.0. All previous work was in 1.1) It is my intent to
    > > stay as close to defaults as possible: i.e. using the most generic
    > > techniques
    > > possible with as little coding as possible.
    > >
    > > My existing database table has some datetime field values that are null.
    > > I
    > > have a page with a detailsview bound to a record in that table. The
    > > datetime fields on my webpage are templates. The read-only screen has no
    > > problem displaying the record, but when I hit the Edit link, the page
    > > crashes
    > > with the message: 'Conversion from type 'DBNull' to type 'Date' is not
    > > valid.' So far I have not been able to intercept this in VB code.
    > >
    > > Apparently it is useless to set the field's xsd default property to
    > > something like '1/1/1900' or '1/1/1753'. I still get the crash. Also I
    > > cannot set the NullValue property to anything other than (Throw Exception)
    > > when the field is a datetime.
    > >
    > > I'm getting the impression from my reading that the best approach is to
    > > not
    > > permit null datetimes in the first place and that I should simply revise
    > > the
    > > database table.
    > >
    > > Suggestions?

    >
    >
    >


  4. Default Re: Design issue: Handling null datetimes from legacy databases.

    This is one reason to go to the custom business object model, instead of
    relying on "quickie" (rapid development) DataSets.

    See:
    http://sholliday.spaces.live.com/Blo...842A!140.entry

    for an example of custom business objects/ custom collections.






    "B. Chernick" <BChernick@discussions.microsoft.com> wrote in message
    news:3E37B883-74A4-4857-AFE3-5920B1C816DF@microsoft.com...
    > Thanks but so far I don't get it. I simply dragged a table onto the xsd
    > and
    > bound it to a detailsview with almost no coding. Is this type of code
    > (the
    > c-sharpcorner example) supposed to be put in the xsd's code behind? The
    > xsd
    > itself can't handle nullable declarations.
    >
    > "sloan" wrote:
    >
    >> http://www.google.com/search?hl=en&q...+nullable+C%23
    >>
    >> http://www.c-sharpcorner.com/UploadF...abletypes.aspx
    >>
    >>
    >> You can google search "nullable datetime" and find some stuff.
    >>
    >> The second URL above is one I picked.
    >>
    >>
    >> Luckily, you are at using (at least) 2.0.
    >>
    >>
    >>
    >> .........
    >>
    >>
    >>
    >>
    >> "B. Chernick" <BChernick@discussions.microsoft.com> wrote in message
    >> news:18012C94-C53D-49BB-BE29-BDA5A4278EEA@microsoft.com...
    >> > I'm writing a demo website in VB/Dot Net 2.0. The database is SQL 2000
    >> > and
    >> > the design is at least partially legacy. (And this is the first real
    >> > web
    >> > work I've done in 2.0. All previous work was in 1.1) It is my intent
    >> > to
    >> > stay as close to defaults as possible: i.e. using the most generic
    >> > techniques
    >> > possible with as little coding as possible.
    >> >
    >> > My existing database table has some datetime field values that are
    >> > null.
    >> > I
    >> > have a page with a detailsview bound to a record in that table. The
    >> > datetime fields on my webpage are templates. The read-only screen has
    >> > no
    >> > problem displaying the record, but when I hit the Edit link, the page
    >> > crashes
    >> > with the message: 'Conversion from type 'DBNull' to type 'Date' is not
    >> > valid.' So far I have not been able to intercept this in VB code.
    >> >
    >> > Apparently it is useless to set the field's xsd default property to
    >> > something like '1/1/1900' or '1/1/1753'. I still get the crash.
    >> > Also I
    >> > cannot set the NullValue property to anything other than (Throw
    >> > Exception)
    >> > when the field is a datetime.
    >> >
    >> > I'm getting the impression from my reading that the best approach is to
    >> > not
    >> > permit null datetimes in the first place and that I should simply
    >> > revise
    >> > the
    >> > database table.
    >> >
    >> > Suggestions?

    >>
    >>
    >>




+ Reply to Thread

Similar Threads

  1. NULL handling
    By Application Development in forum C
    Replies: 6
    Last Post: 10-25-2007, 07:29 PM
  2. NULL handling
    By Application Development in forum C
    Replies: 2
    Last Post: 10-24-2007, 11:49 PM
  3. Replies: 4
    Last Post: 09-11-2007, 02:58 PM
  4. difference in if and iff handling a null value
    By Application Development in forum basic.visual
    Replies: 2
    Last Post: 02-17-2005, 01:16 AM
  5. Dialog design issue (exeption handling across multiple JPanes)
    By Application Development in forum Java
    Replies: 0
    Last Post: 01-27-2004, 09:48 AM