Exception when setting property in business object

  • Thread starter Thread starter jkeel
  • Start date Start date
J

jkeel

Dim _x as string

I get an error when I do the following and can't figure out why.

reader.GetValue("X") is a null value in the database.

_x =
IIF(reader.isDBNull(reader.GetOrdinal("X")),"",reader.GetValue("X"))

although if I do this I receive no error (which makes perfect sense)

_x = IIF(reader.isDBNull(reader.GetOrdinal("X")),"","")


It looks as though in the first example it is bombing out because the
false part of the IIF statement, reader.GetValue("X") is null. Why is
it even evaluating that part of the statement? It should only be
evaluating the true part which is returning an empty string.

Any help would be greatly appreciated.

Jason
 
Dim _x as string

I get an error when I do the following and can't figure out why.

reader.GetValue("X") is a null value in the database.

_x =
IIF(reader.isDBNull(reader.GetOrdinal("X")),"",reader.GetValue("X"))

although if I do this I receive no error (which makes perfect sense)

_x = IIF(reader.isDBNull(reader.GetOrdinal("X")),"","")

It looks as though in the first example it is bombing out because the
false part of the IIF statement, reader.GetValue("X") is null. Why is
it even evaluating that part of the statement? It should only be
evaluating the true part which is returning an empty string.

Any help would be greatly appreciated.

Jason

Hello Jason:
Try reader = DbNull.Value in comparison.
Best regards.
Oscar Acosta
 
Dim _x as string

I get an error when I do the following and can't figure out why.

reader.GetValue("X") is a null value in the database.

_x =
IIF(reader.isDBNull(reader.GetOrdinal("X")),"",reader.GetValue("X"))

although if I do this I receive no error (which makes perfect sense)

_x = IIF(reader.isDBNull(reader.GetOrdinal("X")),"","")

It looks as though in the first example it is bombing out because the
false part of the IIF statement, reader.GetValue("X") is null. Why is
it even evaluating that part of the statement? It should only be
evaluating the true part which is returning an empty string.

Any help would be greatly appreciated.

Jason

Sorry, i meant:
reader.GetOrdinal("X") = DbNull.Value
 

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

Back
Top