Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi guys,

I want to retrieve array of bytes data from database and receive it in byte array like this:

VB
Dim _MemoryStream As New System.IO.MemoryStream()
Dim _BinaryFormatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
_BinaryFormatter.Serialize(_MemoryStream, ourCommand.ExecuteScalar())

UserPasswordKey = _MemoryStream.ToArray()


but it give me error for this line of code:

VB
_BinaryFormatter.Serialize(_MemoryStream, ourCommand.ExecuteScalar())


I try at first to do like that:

VB
Dim UserPasswordKey As Byte() = ourCommand.ExecuteScalar()


but i must convert ExecuteScalar from object to byte() firstly

???
Posted
Updated 4-Apr-17 1:38am

1 solution

If it IS a byte array, cast it. If it's not, what is it ? An object is not anything.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900