-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.

0

1 Answer 1

0

you have to ask if it is DBNull

presentation.presentationDocBinData =dr["presentationDocBinData"]==DBNull.Value?null:(Byte[])dr["presentationDocBinData"];
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.