views:

32

answers:

1

Reading binary data out of the database, and I need to convert it back into a Digital Persona fingerprint template. I'm not familiar with serialization and deserialization, so I could use a bit of help. Here's what I tried:

Dim rsBioData As SqlDataReader = SQL.ExecuteReader
Dim byteTemplate As Byte
Dim memStreamTemplate As MemoryStream
If rsBioData.HasRows Then
    While rsBioData.Read
        byteTemplate = rsBioData("BiometricData")
        memStreamTemplate = New MemoryStream(byteTemplate)
        Me.Template = DirectCast(template.DeSerialize(memStreamTemplate), DPFP.Template)
    End While
End If
rsBioData.Close()

I receive an error that template.DeSerialize(memStreamTemplate) does not create a value.

For kicks, here's how I serialized the object to place it into the database. I assume this part is working, since the binary data shows up in SQL server--just can't read it back out to see.

Dim str As New MemoryStream
Enroller.Template.Serialize(str)
Dim serializedTemplate As Byte() = str.ToArray()
SQL.Parameters.AddWithValue("biometricData", serializedTemplate)

Thanks

A: 

Here's how I was finally able to do it. I was SO close the first time around.

            byteTemplate = rsBioData("BiometricData")
            memStreamTemplate = New MemoryStream(byteTemplate)
            Me.Template.DeSerialize(memStreamTemplate)
Brad