Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Yet another OleDBDataAdapter quirk, the EMPTY(FIELDNAME) condition

Posted on 2006-06-21
7
Medium Priority
?
203 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

636 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