Solved

Yet another OleDBDataAdapter quirk, the EMPTY(FIELDNAME) condition

Posted on 2006-06-21
7
196 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET bulk update  of a table from another table 4 44
LINQ - C# to VB convertion 12 56
Advice on Xojo as a development tool over VB. 4 55
Web Form VB.Net  import CSV 4 38
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 …
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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