Solved

Yet another OleDBDataAdapter quirk, the EMPTY(FIELDNAME) condition

Posted on 2006-06-21
7
194 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now