I have a column value in Hash format in db and column datatype is varbinary(8000).I convert it into byte array. Problem is some time this column value has null value,now in my code I want to check if column value has null value then return default value of byte array,otherwise return column value using following code
<pre> objUser.Password_Hash = IIf(reader("Password_Hash") Is Nothing, {}, reader("Password_Hash"))
System.InvalidCastException: Unable to cast object of type 'System.Byte' to type 'System.Byte[]'.
objUser.Password_Hash = If(reader.IsDBNull(reader.GetOrdinal("Password_Hash")), New Byte() {}, DirectCast(reader("Password_Hash"), Byte()))
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)