Click here to Skip to main content
14,661,186 members
Rate this:
Please Sign up or sign in to vote.
See more:
Im using digitalpersona u.are.u 4500 fingerprint reader.

This is the codes I used to save fingerprint template to database:
Dim str As New MemoryStream
Enroller.Template.Serialize(str)
Dim serializedTemplate As Byte() = str.ToArray()
Dim bytes() as Byte = serializedTemplate
comm.Parameters.AddWithValue("@Emp_FPrint", bytes)


The problem is when I try to retrieve fingerprint from the database and Deserialize it , I have this error:

"Conversion from type Byte() to type Byte is not valid."

What I have tried:

Sub OnComplete(ByVal Capture As Object, ByVal ReaderSerialNumber As String, ByVal Sample As DPFP.Sample) Implements DPFP.Capture.EventHandler.OnComplete
MakeReport("The fingerprint sample was captured.")
SetPrompt("Scan the same fingerprint again.")
Process(Sample)

CheckTemplate()
If ds1MaxRow > 0 Then
For i = 0 To ds1MaxRow - 1
' byteArray = CType(ds1VerifyFPrintp.Tables("TestImage").Rows(i).Item(1), Byte())
con1 = New SqlConnection
con1.ConnectionString = "Data Source=ERSERVER;Initial Catalog=Timekeeping;User ID=sa;Password=sa"
Dim thequery As String = "Select Emp_FPrint from TestImage "
con1.Open()
Dim cmd As SqlCommand = New SqlCommand(thequery, con1)
Dim rsBioData As SqlDataReader = cmd.ExecuteReader

Dim byteTemplate As Byte
Dim memStreamTemplate As MemoryStream
If rsBioData.HasRows Then
While rsBioData.Read
byteTemplate = rsBioData("Emp_FPrint") ''''''''ERROR HERE : Conversion from type 'Byte()' to type 'Byte' is not valid. '''''''
memStreamTemplate = New MemoryStrea(byteTemplate)
Me.Template.DeSerialize(memStreamTemplate)
End While
End If '''''''STUCK UNTO THIS LINE''''''''''

Dim features As DPFP.FeatureSet = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification)

' Check quality of the sample and start verification if it's good
If Not features Is Nothing Then
' Compare the feature set with our template
Dim result As DPFP.Verification.Verification.Result = New DPFP.Verification.Verification.Result()
Verificator.Verify(features, Template, result)
' UpdateStatus(result.FARAchieved)
If result.Verified Then
MakeReport("The fingerprint was VERIFIED.")
Else
MakeReport("The fingerprint was NOT VERIFIED.")
End If
End If

Next i
End If
End Sub
Posted
Updated 19-Aug-19 22:34pm

Rate this:
Please Sign up or sign in to vote.

Solution 1

Dim byteTemplate As Byte

The error message is quite clear. You cannot deserialize an array of Bytes into a single Byte.
   
Comments
ajownme 10-Mar-16 20:24pm
   
I try also this . but I got error : "'System.NullReferenceException'. Additional information: Object reference not set to an instance of an object."


Dim byteTemplate() As Byte
Dim memStreamTemplate As MemoryStream
If rsBioData.HasRows Then
While rsBioData.Read
byteTemplate = rsBioData("Emp_FPrint")
memStreamTemplate = New MemoryStrea(byteTemplate)
Me.Template.DeSerialize(memStreamTemplate) '''''''ERROR HERE''''''''''''
End While
End If
Richard MacCutchan 11-Mar-16 3:17am
   
That just looks like you really need to go back to your study guides. Please re-read my message above, and allocate a proper array for your deserialised data.
Rate this:
Please Sign up or sign in to vote.

Solution 2

i think it should be like this

Dim byteTemplate As Byte()
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100