我现在可以使用此代码将指纹直接保存到数据库...
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 cn As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=dataBEST;Integrated Security=True;Pooling=False")
Dim cmd As SqlCommand = New SqlCommand("INSERT INTO fininger_table VALUES(@FIRSTNAME, @LASTNAME, @FINGERPRINT)", cn)
cmd.Parameters.Add("FIRSTNAME", SqlDbType.VarChar).Value = CaptureForm.tboxFname.Text
cmd.Parameters.Add("LASTNAME", SqlDbType.VarChar).Value = CaptureForm.tboxLname.Text
cmd.Parameters.Add("FINGERPRINT", SqlDbType.Image).Value = bytes
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
现在?如何检索该指纹并与用户匹配?顺便说一句,我的设备是DIGITAL PERSONA..tnx提前
答案 0 :(得分:0)
应该相当简单。
1.) Simply fetch the data of your fingerprint using SqlDataReader
2.) Store the fetched value to a variable
3.) compare your bytes() variable with the fetched value.
如果您不熟悉如何使用datareader,请考虑此功能
Function MSselectspecific(ByVal SQLComnd As String)
Dim Sqlconn as New SQLConnection("your connection parameters")
Dim sqlcommand As New SqlCommand(SQLComnd, Sqlconn)
Dim reader As SqlDataReader
Dim resulta As String = Nothing
Dim x As Integer = 0
Try
Sqlconn.Open()
reader = sqlcommand.ExecuteReader
While reader.Read
resulta = reader(0)
x = x + 1
Exit While
End While
Sqlconn.Close()
If x > 0 Then
Return resulta
Else
Return Nothing
End If
Catch ex As Exception
Sqlconn.Close()
MsgBox("Selectspecific Details Error " & vbNewLine & ex.ToString)
Return Nothing
End Try
End Function
并像这样使用它(以及保存用户指纹数据的变量)
*注意:bytes()是代码中包含指纹数据的部分,即(Dim bytes() As Byte = br.ReadBytes(CType(fingerprintData.Length, Int32))
)
if bytes() = val(MSSelectSpecific("select FINGERPRINT from fininger_table where FINGERPRINT = " & bytes() & ";")) then
msgbox("Congrats! It's a match")
End If
请注意,我使用val,因为您要比较两个数值。