0

I'm 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.

This is the code I used to retrieve and Deserialize fingerprint:

    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 MemoryStream(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
Yog
  • 112
  • 12
ajownme
  • 1
  • 2
  • try declaring '`byteTemplate` as `byteTemplate()` – Yog Mar 10 '16 at 08:55
  • I already try it and stuck on line : Me.Template.DeSerialize(memStreamTemplate) and got this error : "System.NullReferenceException " Additional information: Object reference not set to an instance of an object. – ajownme Mar 10 '16 at 09:04
  • have you debug your code? Is it getting anything in `byteTemplate`? – Yog Mar 10 '16 at 10:05
  • Check [this](https://msdn.microsoft.com/en-us/library/e55f3s5k.aspx) and also check [this](http://stackoverflow.com/questions/4736155/how-do-i-convert-byte-to-stream-in-c) – Yog Mar 10 '16 at 10:12
  • I already check the byteTemplate() and it has a "Length = 275124". – ajownme Mar 11 '16 at 02:03
  • you are getting `NullReferenceException`, so can you do this `memStreamTemplate.Write(byteTemplate, 0, byteTemplate.Length)`. May this help you. – Yog Mar 11 '16 at 06:25
  • thanks for your assistance , I've got pass through that line and move on to the next line of codes. This is what I've done : dim Template As DPFP.Template = New DPFP.Template() – ajownme Mar 11 '16 at 08:07

1 Answers1

0

Try this

Dim cmd As New MySqlCommand("SELECT * FROM employeefp ", conn) Dim rdr As MySqlDataReader = cmd.ExecuteReader()

While (rdr.Read())
    Dim MemStream As IO.MemoryStream
    Dim fpBytes As Byte()

    fpBytes = rdr("FP")
    MemStream = New IO.MemoryStream(fpBytes)

    Dim templa8 As DPFP.Template = New DPFP.Template()
    templa8.DeSerialize(MemStream)

    Dim tmpObj As New AppData
    tmpObj.No = rdr("No").ToString()
    tmpObj.Template = templa8
    FPList.Add(tmpObj)
End While
Epson
  • 1