-1

I'm trying to read the null value from my SQL.

The column presentationDocBinData is Nullable and it is a NULL.

So i tried reading it this way,

presentation.presentationDocBinData = (Byte[])dr["presentationDocBinData"];

But according to it, they're unable to read the null value that it receives. It says

Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.

So is there anyway to give it a default value or leave it blank if it is possible? it works fine with a value in it though.

Trent
  • 15
  • 6

1 Answers1

0

you have to ask if it is DBNull

presentation.presentationDocBinData =dr["presentationDocBinData"]==DBNull.Value?null:(Byte[])dr["presentationDocBinData"];
st mnmn
  • 3,555
  • 3
  • 25
  • 32