?
Solved

Yet another OleDBDataAdapter quirk, the EMPTY(FIELDNAME) condition

Posted on 2006-06-21
7
Medium Priority
?
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

765 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