Click here to Skip to main content
14,695,615 members
Please Sign up or sign in to vote.
1.00/5 (1 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
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.")

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 "
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)
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.")
MakeReport("The fingerprint was NOT VERIFIED.")
End If
End If

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

Dim byteTemplate As Byte

The error message is quite clear. You cannot deserialize an array of Bytes into a single Byte.
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.
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900