473,789 Members | 3,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataView.RowFil ter IsNull: DBNull in column of boolean datatype

Hi All:

I need to get (filter in) some dataview's rows with DBNULLs in column of boolean type:
Actually to get the only rows with DBNULL, I use code like this:

DV.RowFilter = "(IsNull(MyBool eanColumnName, True) = True) AND (IsNull(MyBoole anColumnName, False) = False)"

or ex.
DV.RowFilter = "(IsNull(MyInte gerColumnName, 1) = 1) AND (IsNull(MyInteg erColumnName, 0) = 0)"
for columns of Integer...

I know - looks strange, but it seems to work.
However I'm not sure if it's correct...

Is there any better way to get only dbnulls from boolean column?

Thanks
Marcin Dzióbek

Jun 27 '08 #1
6 17511
Your method seems OK except if you are trying to fix a data table on a
server DB where a boolean column contains null values -- I would fix
that at the server - set a default value of 0 for false and everywhere
that is null -- set to false. Then make that boolean column to not
allow null values (will be a bit column).

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #2
Hi Rich:

Thaks for replay:
.... except if you are trying to fix a data table on a
server DB where a boolean column contains null values -- I would fix
that at the server - set a default value of 0 for false and everywhere
that is null -- set to false. Then make that boolean column to not
allow null values (will be a bit column).
1. I can't use RDBMS to "fix" table... I'm just trying to develop user control: another custom datagridview with
filter's tools.
It has a property - datasource - where the consumer will assign reference to "his own" datatable. What if consumer will
use ReadXml to create dataset and datatable?

2. IMHO: table "where a boolean column contains null values" is OK - I wouldn't change that. If we eliminated null
values by changing table/database project in RDBMS, we still cannot avoid null values in System.Data.Dat aTable object.
I'm not sure even if datadapter.fill method sets DataColumn.Allo wDBNull and DataColumn.Defa ultValue properties; it may
depend MissingSchemaAc tion property and kind of RDBMS... but ofcourse I may be wrong.

--
Marcin Dzióbek

Jun 27 '08 #3
Hello again,

my explanation pertains primarily to MS Sql Server. I am fairly certain
that if a table on the backend DB contains a bit column to be used as a
boolean column -- it would be counter intuitive to have 3 values -
True/Null/False. The field should either be true or false if it is a
boolean column. Thus, if your project is using this column as a boolean
and the Null value cannot be eliminated - then the suggestion that I
offer is that I wish you well. My question is this: why compensate for
something down the road instead of fixing it at the source?

IF there is no possibility of fixing your problem at the source, then it
appears that the method you are asking about is the only way for you to
continue with your project.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #4
Marcin Dzióbek wrote:
Hi All:

I need to get (filter in) some dataview's rows with DBNULLs in column
of boolean type: Actually to get the only rows with DBNULL, I use code like
this:

DV.RowFilter = "(IsNull(MyBool eanColumnName, True) = True) AND
(IsNull(MyBoole anColumnName, False) = False)"
or ex.
DV.RowFilter = "(IsNull(MyInte gerColumnName, 1) = 1) AND
(IsNull(MyInteg erColumnName, 0) = 0)" for columns of Integer...

I know - looks strange, but it seems to work.
However I'm not sure if it's correct...

Is there any better way to get only dbnulls from boolean column?
It is so simple, you will kick yourself:

DV.RowFilter = "MyColumnNa me Is Null"
Jun 27 '08 #5
Hi Steve:
It is so simple, you will kick yourself:

DV.RowFilter = "MyColumnNa me Is Null"
You're absolutely right! How could I live without that...
Now I kick myself :)

THANKS!

--
Marcin Dzióbek

Jun 27 '08 #6
>... My question is this: why compensate for
something down the road instead of fixing it at the source?
IMHO there is nothing to fix. I just don't agree that null values are wrong.
IF there is no possibility of fixing your problem at the source, then it
appears that the method you are asking about is the only way for you to
continue with your project.
Steve opened my eyes... there is better method (should be mentioned in MSDN DataView.RowFil ter's help page).

Thanks
--
Marcin Dzióbek

Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2901
by: David | last post by:
Hi, I use DataView to filter my record. But when I use: ls_filter += " and DATEPART(hh, CA103)=" + i ; mydv.RowFilter = ls_filter; I got error. How should I filter by hour using DataView.Rowfilter?
8
4784
by: KC | last post by:
For a DataView.Rowfilter can I use more than one expression? I want to filter out two different things. For example can I take: dv.RowFilter = "MTX <> 'Customer Forcast'" and dv.RowFilter = "MTX <> 'Actual vs. Forcast'"
1
9152
by: Engineerik | last post by:
According to what I see in the manuals I should be able to use regular expressions with the rowfilter property of a dataview but I keep getting errors. Example: I want to find any rowview where column APCode is not a string of exactly 3 uppercase letters. Assume dtBAirpt is an instance of a datatable having a column APCode Code snippet Try Dim dvTest As New DataView(dtBAirpt, _
7
5628
by: Rich | last post by:
Hello, I am pulling master data from one master table and detail data from two detail tables. The rows from the master data are displayed in textboxes on my form which are bound to the data with databinding. The data from the 2 detail tables are displayed in 2 datagridviews. I filter each datagridview with a Dataview object using the dataview.Rowfilter property. This is sort of working except that I am getting an except on one of my...
3
10260
by: randy1200 | last post by:
I have a DataView (dv) that includes a StartDate DateTime column. I'd like to return the DataView record that contains a StartDate value closest to my IncidentDate value: string filter = String.format("StartDate nearest {0}", IncidentDate); dv.Rowfilter = filter; Of course, there's no nearest function.
0
1527
by: neeraj | last post by:
Hi, all Could anny one give me help how can I use like operator with these data types "integer , datetime or boolean" in DataView.RowFilter Actually when I try to get the data from dataview using rowfilter with like operator Its working fine when data type of searching column is "string" . But if data type is "integer , datetime or boolean" its throws
2
18942
by: neeraj | last post by:
Hi, all Could anny one give me help how can I use like operator with these data types "integer , datetime or boolean" in DataView.RowFilter Actually when I try to get the data from dataview using rowfilter with like operator Its working fine when data type of searching column is "string" . But if data type is "integer , datetime or boolean" its throws
1
2712
by: AlexW | last post by:
Hi I am in the process of developing an inventory application in visual basic. I keep coming up against a problem with using the dataview.rowfilter property. Basically what happens is this: -a global dataview is created -The user enters new part information into a form. -A function is called to check to see if the part is a new part (so that two identical part numbers are not added to the database. -The check is done by setting the...
5
11842
by: AlexW | last post by:
Hi I am in the process of developing an inventory application in visual basic. I keep coming up against a problem with using the dataview.rowfilter property. Basically what happens is this: -a global dataview is created -The user enters new part information into a form. -A function is called to check to see if the part is a new part (so that two identical part numbers are not added to the database. -The check is done by setting the...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6768
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.