Null Values eliminates the row?

  • Thread starter Thread starter jp2msft
  • Start date Start date
J

jp2msft

I have a TableAdapter linked to an SQL Server 2000 table. Some of the cells
have null string values.

In VS2005, I can preview the data linked by the TableAdapter in design mode,
and all fields are displayed - even the ones with cells containing null
values (they just show "null" in the cell).

When I run my application, I create a DataTable and use an SqlDataAdapter
and fill it using the TableAdapter.

To search my data, I use the DataTable's Select method; however, any row
that contains a null value will not show up in the DataRows that are returned.

Has anyone ever encountered something like this?

Why is this happening, and how do I get around it?
 
Found a solution here: http://tinyurl.com/28u3xg

Basically, I edited the SELECT statement that my TableAdapter used. If the
IS NULL, I replaced it with a single space.

If anyone knows of any issues I'm likely to run into because of this, please
let me know!
 
What I have encountered is similar, but not quite the same.

I've noticed that if your query results in a DataTable where all rows have a
null value for a given column, that the column will be part of the table,
but if you use the GetXML method that column will not be serialized at all.

-Scott
 
The problem I have with that solution is that it adds business logic to the
data layer. If you are looking for a strong separation of application
logic, this solution doesn't cut it. I'd do a null check in your business
layer and if found, change the data value from null to String.Empty, rather
than embed a space char.

-Scott
 
Scott,

That is not something you have encoutered. It is just the standard behaviour
of XML datasets.

Don't become angry, I am just smilling friendly and could not resist.

:-)

Cor
 
That is not something you have encoutered. It is just the standard
behaviour of XML datasets.

Don't become angry, I am just smilling friendly and could not resist.

:-)

Cor

I'm sure there's a language issue here, but I was saying that this is the
standard behavior. And, I must disagree, I *have* encountered it.

:)
 
I'm just glad I'm not the only one who's seen this behavior. I couldn't
figure out what was wrong with the code!
 
Back
Top