Object null but read as empty?

P

PokerMan

I have this

object o = ds.Tables[0].Rows.ItemArray[j];

the item read from my dataset is null. I check on the next line :

if(o!= null)
//then do something

My prob is the object o is getting passed that if statement then i crash, in
debug it shows it with a value of {}.

So what does "{}" mean and how do i check for that?
And why does it not get set to null?

Its read from a database and the value is null there.

Thanks
 
P

Peter Bradley

PokerMan said:
I have this

object o = ds.Tables[0].Rows.ItemArray[j];

the item read from my dataset is null. I check on the next line :

if(o!= null)
//then do something

My prob is the object o is getting passed that if statement then i crash,
in debug it shows it with a value of {}.

So what does "{}" mean and how do i check for that?
And why does it not get set to null?

Its read from a database and the value is null there.

Thanks


The {} represents DbNull, I think. If I'm right, you'll need to check for
DbNull and not for null.

Cheers


Peter
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Cause a "null" ni the DB is interpreted as DBNull.Value in the code.

Check for DBNull.Value instead
 

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