Vb.net 如何从数据库中检索指纹的序列化模板?

Vb.net 如何从数据库中检索指纹的序列化模板?,vb.net,Vb.net,我使用的是digitalpersona u.are.u 4500指纹阅读器 这是我用来将指纹模板保存到数据库的代码: Dim str As New MemoryStream Enroller.Template.Serialize(str) Dim serializedTemplate As Byte() = str.ToArray() Dim bytes() as Byte = serializedTemplate comm.Parameters.AddW

我使用的是
digitalpersona u.are.u 4500
指纹阅读器

这是我用来将指纹模板保存到数据库的代码:

    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)
问题是,当我尝试从数据库检索指纹并对其进行反序列化时,出现以下错误:

从类型“Byte()”到类型“Byte”的转换无效

这是我用来检索和反序列化指纹的代码:

    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
试试这个

Dim cmd作为新的MySqlCommand(“从employeefp中选择*,康涅狄格州) 作为MySqlDataReader=cmd.ExecuteReader()的Dim rdr


尝试将“
byteTemplate
声明为
byteTemplate()
我已经尝试过了,但仍停留在第行:Me.Template.DeSerialize(memStreamTemplate)中,并出现以下错误:“System.NullReferenceException”其他信息:对象引用未设置为对象的实例。是否调试了代码?它是否在byteTemplate中获取任何信息?检查并检查我已经检查了byteTemplate(),它的长度为“275124”。
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