Null Values eliminates the row?

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?
 
J

jp2msft

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!
 
S

Scott M.

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
 
S

Scott M.

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
 
C

Cor Ligthert[MVP]

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
 
S

Scott M.

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.

:)
 
J

jp2msft

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top