473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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?
Nov 26 '07 #1
1 1078
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" <BC*******@discussions.microsoft.comwrote in message
news:18**********************************@microsof t.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?

Nov 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: grz02 | last post by:
Hi, Im an experienced database+software designer and developer, but, unfortunately, anything to do with web-programming and web-systems designs is still a pretty new area to me... (been working...
2
by: Jack | last post by:
Hello, VB6. I have a class. The class receives a bunch of individual items from an asp page, then updates the database. My question is what is the best way you have found to update the...
2
by: Eric Nilsson via .NET 247 | last post by:
I need a good design (pattern?) for working with persistantobjects. This is what has been bothering me, I'm on 3'rd year inuniversity learning computer science, and I am now working on...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
3
by: Wiktor Zychla | last post by:
Hello, my question is rather connected with some aspects of ADO.NET but I've been trying to ask on .dotnet.framework.adonet with no result. I hope someone here can help me. The problem is...
29
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this...
5
by: AAJ | last post by:
Hi Does anyone know of any good publically available set of standards for managing dates when dealing with a database server (in my case SQL Server 2000 and c# VS2005). At the moment, if I...
0
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that...
3
by: puzzlecracker | last post by:
What I currently have and request a suggestion to modularize it public sealed class Connection: BaseConnection{ //I have to process about 30 events public event Handler1=handler1; public...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.