Solved

Yet another OleDBDataAdapter quirk, the EMPTY(FIELDNAME) condition

Posted on 2006-06-21
7
197 Views
Last Modified: 2010-04-23
Take a simple select.

SELECT ID, LAST, FIRST, ORDER
FROM TABLE
WHERE ORDER IS NULL

This will not work in the table I am pulling from because the field is not actually NULL it is blank. For some reason blank and NULL are not the same, maybe tonight after a few glasses of Jack Daniels that will make sense to me. So according to my friend Google the usage of EMPTY(ORDER) should work and behold in the Query Builder is does run !! The problem is when you hit ok it says the select statement cannot be generated. I manually do the select statement in the code, and it still does not run. Am I missing something ?
0
Comment
Question by:ParanoidOne
  • 4
  • 3
7 Comments
 

Author Comment

by:ParanoidOne
ID: 16952882
Oh by the way, what happens when I manually edit the select statement in the code is after launch the dataset comes up empty.
0
 

Author Comment

by:ParanoidOne
ID: 16952942
Ok think I figured it out.

SELECT ID, LAST, FIRST, ORDER
FROM TABLE
WHERE ORDER <> {  /  /    }
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16952960
Have you tried:

    SELECT ID, LAST, FIRST, ORDER
    FROM TABLE
    WHERE ORDER = ''

?

P.S.

    The difference between NULL and empty is that NULL represents a value that has never been set rather than simply not currently having a value. As an example, consider a Table that store the last time a user logged in. If the LastLoggedIn field has a NULL value then this indicates that the user has never signed in.

P.P.S.

    Ideally you shouldn't allow a field to contain NULL unless the NULL-ness actually means something.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:ParanoidOne
ID: 16953613
So you are saying in my new database always have the fields with something, just not NULL ? Having NULL fields are a bad practice then ? I will post again in a sec after this has run and let you know if that works too.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16953684
Using NULL isn't bad practice, its just that a lot of people use NULL when they shouldn't do.

As I mentioned in my previous post, you should really only allow NULL when it means something (i.e. the difference between not currently having a value and never having been set).

If you disallow NULL for text based fields then they will default to an empty string, which also removes the problem of having to check for both NULL and empty.
0
 

Author Comment

by:ParanoidOne
ID: 16953770
What about Date Fields, is that also bad practice ?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 16953807
Date fields are one of the more common places to allow NULL. Because, with Dates a NULL provides the distinction between having never been set and having an arbitary value.

Again, it all depends on whether you need to tell the difference between the value having never been set or not. If you don't need to know if it has ever been set or not then you shouldn't use NULL.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB 2005 Tooltips on Form Load Event 15 34
Disable extension 8 48
Store results in vb.net 3 24
VB.NET Inline If statement 4 14
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question