473,883 Members | 1,646 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 17518
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
2903
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
4789
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
9157
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
5634
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
10264
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
1536
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
18956
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
2718
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
11848
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
9932
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11112
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9559
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...
0
7114
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
5784
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4602
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4205
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3228
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.