welcome to the nasty world that created generics for the .NET framework (v 2.0)

I had the same sort of grief with C# 1.1 where a null date (or number)
might be spat out from a database but I couldn't stick it in a date
(or number) variable, because it didn't accept NULL - I couldn't
convert a dbNull to a DateTime null (nor Int32 null, etc)

in the end I had to do as you did - convert the dbNull to a sentinal
value (eg: DateTime.minValue) that would be looked at (and converted
to "" for display). it was tricker for the "Int.minValue" since I had
to pray that "-64,000" (or whatever) wasn't actually a legit value
that might appear and bite me on the bum.

All of this is now fixed in .NET 2.0 thanks to generics: dates and
numbers can have nulls which tranlates back to inserting a dbNull
nicely. However I am disapointed that ActionScript3 didn't fully go
down this path now being a strong-typed language, considering generics
for Java and .NET is now old news.

Here's the point(s):

* I used to think strongly typed languages and NULL's went
hand-in-hand. But your woes highlights that even weakly typed
languages (like CF) aren't immune

* You need an answer that will cater for other things than just dates.
Dates are only your current problem: it's any non string datatype that
will hit this: ints and floats included. What's a null Int? 0? -1? ""?

* the problem can be avoided (and made more complex) by setting up the
database to never use NULLs: "no such thing as a null field - ever"
(and watch the DBA sparks fly with the for/against arguments)


my 2c on a sunday a'noon.

cheers
barry.b

On 3/4/07, Mike Kear <[EMAIL PROTECTED]> wrote:
> Thanks Blair, I'd figured that bit out.    But what do i do?  If i want to
> CFQUERYPARAM every field in order to get the query caching benefits,  I have
> to have every field CFQUERYPARAM'ed.
>
> But if there's no date to insert,  it bombs.
>
> So where do i go now?
>
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> Adobe Certified Advanced ColdFusion Developer
> AFP Webworks
> http://afpwebworks.com
> ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month
>
>
>
>
> On 3/4/07, Blair McKenzie <[EMAIL PROTECTED]> wrote:
> > Your database may accept an empty string as a date, but that doesn't mean
> that cfqueryparam does.
> >
> > Blair
> >
> >
>
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to