如何使用vb.net保存和检索MySql指纹模板?

时间:2016-01-27 18:47:20

标签: mysql vb.net vb.net-2010 fingerprint

我对vb.net和mysql上的指纹这个东西很新。我刚开始尝试使用digitalpersona u.are.u 4500而且我不知道如何将模板保存到Mysql数据库。我也想从Mysql中检索数据。这是代码。谢谢! `

Private Enroller As DPFP.Processing.Enrollment

Protected Overrides Sub Init()
    MyBase.Init()
    MyBase.Text = "Fingerprint Enrollment"
    Enroller = New DPFP.Processing.Enrollment()     ' Create an enrollment.
    UpdateStatus()
End Sub

Protected Overrides Sub Process(ByVal Sample As DPFP.Sample)
    MyBase.Process(Sample)

    ' Process the sample and create a feature set for the enrollment purpose.
    Dim features As DPFP.FeatureSet = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Enrollment)

    ' Check quality of the sample and add to enroller if it's good
    If (Not features Is Nothing) Then
        Try
            MakeReport("The fingerprint feature set was created.")
            Enroller.AddFeatures(features)        ' Add feature set to template.
        Finally
            UpdateStatus()

            ' Check if template has been created.
            Select Case Enroller.TemplateStatus
                Case DPFP.Processing.Enrollment.Status.Ready    ' Report success and stop capturing
                    RaiseEvent OnTemplate(Enroller.Template)
                    SetPrompt("Click Close, and then click Fingerprint Verification.")
                    StopCapture()

                Case DPFP.Processing.Enrollment.Status.Failed   ' Report failure and restart capturing
                    Enroller.Clear()
                    StopCapture()
                    RaiseEvent OnTemplate(Nothing)
                    StartCapture()

            End Select
        End Try
    End If
End Sub

Protected Sub UpdateStatus()
    ' Show number of samples needed.
    SetStatus(String.Format("Fingerprint samples needed: {0}", Enroller.FeaturesNeeded))
End Sub

Private Sub EnrollmentForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

End Sub
Private Sub InitializeComponent()
    Me.SuspendLayout()
    '
    'bioenrollment
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.ClientSize = New System.Drawing.Size(1266, 630)
    Me.Name = "bioenrollment"
    Me.ResumeLayout(False)
    Me.PerformLayout()

End Sub`

2 个答案:

答案 0 :(得分:0)

DigitalPersona指纹识别器允许您将指纹序列化为XML文件......您只需将其作为Varchar(MAX)存储在数据库中。

答案 1 :(得分:0)

尝试使用此代码进行插入

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button1.Click

    Dim fingerprintData As MemoryStream = New MemoryStream
    Template.Serialize(fingerprintData)
    fingerprintData.Position = 0
    Dim br As BinaryReader = New BinaryReader(fingerprintData)
    Dim bytes() As Byte = br.ReadBytes(CType(fingerprintData.Length, Int32))

    Dim SQLconnect As New SQLite.SQLiteConnection()
    Dim SQLcommand As SQLiteCommand
    SQLconnect.ConnectionString = "data source=C:\Users\mypc\Documents\MatrixDbase.s3db"
    SQLconnect.Open()
    SQLcommand = SQLconnect.CreateCommand

    SQLcommand.CommandText = "INSERT INTO Longin (id, Fname, Lname, Pic) VALUES ('" & TextBox1.Text & "', '" & TextBox2.Text & "', '" & TextBox3.Text & "', @Pic)"

    SQLcommand.Parameters.AddWithValue("@Pic", bytes)
    'Runs Query
    SQLcommand.ExecuteNonQuery()
    SQLcommand.Dispose()
    SQLconnect.Close()

End Sub