Select Fingerprint Tempelate from Sql Database and Match the Tempelate

aliyuusman4u

New member
Joined
May 5, 2017
Messages
4
Location
Nigeria
Programming Experience
10+
Hello,
I am new in this forum and i had from a friend that this group was fantastic , however, i have an issue ,i have develop Biometric application using Securegen SDk, i have done the Enrollment process and i was able to save the template in SQL Server Database. But i have an issue retrieving the template and do the Verification process. please i need help from you. please find bellow my code that does the matching. all i need is how to get the Stored template for all from Database and do the matching. please find my code bellow
VB.NET:
        If (Me.m_StoredTemplate Is Nothing) Then
            Me.StatusBar.Text = "No data to verify"
            Return
        End If


        Dim fingerpos_str() As String = New String() {"Unknown finger", "Right thumb", "Right index finger", "Right middle finger", "Right ring finger", "Right little finger", "Left thumb", "Left index        finger", "Left middle finger", "Left ring finger", "Left little finger"}
        Dim err As Int32
        Dim finger_pos As SGFPMFingerPosition = SGFPMFingerPosition.FINGPOS_UK
        Dim finger_found As Boolean = False
       
            Dim sample_info As SGFPMANSITemplateInfo = New SGFPMANSITemplateInfo
            err = Me.m_FPM.GetAnsiTemplateInfo(Me.[B][COLOR=#b22222]m_StoredTemplate[/COLOR][/B], sample_info)
            Dim i As Integer = 0
            Do While (i < sample_info.TotalSamples)
                Dim matched As Boolean = False
                err = Me.m_FPM.MatchAnsiTemplate(Me.[B][COLOR=#b22222]m_StoredTemplate[/COLOR][/B], i, Me.m_VrfMin, 0, Me.m_SecurityLevel, matched)
                If matched Then
                    finger_found = True
                    finger_pos = CType(sample_info.SampleInfo(i).FingerNumber, SGFPMFingerPosition)
                    Exit Do
                End If


                i = (i + 1)
            Loop


        If (err = SGFPMError.ERROR_NONE) Then
            If finger_found Then
                Me.StatusBar.Text = ("The matched data found. Finger position: " + fingerpos_str(CType(finger_pos, Int32)))
            Else
                Me.StatusBar.Text = "Cannot find a matched data"
            End If

NOTE: m_StoredTemplate is the Variable that will hold the binary tempelate that is saved in the database.


Thank you so much
 
You would retrieve this data the same way you would retrieve any data from a SQL Server database. If you're already able to store the data then you presumably already know the basics of ADO.NET. You simply execute a SELECT statement to get the data you want. You can use a data adapter to populate a DataTable or, if the data is read-only, use a data reader. If you're just getting one value at a time then you can call ExecuteScalar.
 
I have created a class called verification please find the class bellow

Public Class verifivation
Public Property computerno As String
Get
End Get
Set(value As String)
End Set
End Property


Public Property tempelate As Byte
Get
End Get
Set(value As Byte)
End Set
End Property


End Class

And i create a sub procedure to use the class , please find the sub procedure bellow.

Public Sub idenification()
Dim Employees As List(Of verifivation) = New List(Of verifivation)


Dim Mycon As New Utility
Dim conn As SqlConnection = New SqlConnection()
conn.ConnectionString = Mycon.Connection
Dim cmd As SqlCommand = New SqlCommand("select computerno,tempelates from employee", conn)
Dim dr As SqlDataReader
Try
conn.Open()
dr = cmd.ExecuteScalar


While dr.Read
Employees.Add(New verifivation)
End While


dr.Close()
Catch exp As Exception
Throw
Finally
conn.Close()
End Try


End Sub

I want if i user place his finger on Fingerprint scanner , the software should Loop through the database and Match the template until the template is found . if found return the computerno else return nothing. can you help me with this sir.

Thank you so much
 
Firstly, you've made your code harder to read. Please post code snippets as plain text in appropriate code formatting tags, for which there are buttons on the advanced editor tool bar. That generally means:

[xcode=vb]your code here[/xcode]

but, if you want specific formatting, e.g. to bold a line, then use:

[code]your code here[/code]

As for the issue, ExecuteScalar does not return a SqlDataReader. As I said - and as the documentation states, ExecuteScalar is for retrieving a single value. If you want to retrieve multiple values then you call ExecuteReader to get a data reader. You can then use a loop as you have to get the rows of data. Inside the loop, you can get the fields of the current row by name or index and use them however is appropriate for your application. You may find this thread useful for the basics of ADO.NET:

Retrieving and Saving Data in Databases
 
Hello,

Thank you for your help, and with your help i was able to come up with something like this , i am just trying to know how loop through and match the stored template with the new scanned template. please find the Function i create to filter the Fingerprint template i stored in database.
 Function PopulateTempelates(ByVal SQLComnd As String)
        Dim Mycon As New Utility
        Dim Sqlconn As New SqlConnection(Mycon.Connection)
        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

Please let me know how to loop trough the database and match the fingerprint data
 If (Me.m_StoredTemplate Is Nothing) Then
            Me.StatusBar.Text = "No data to verify"
            Return
        End If


        Dim fingerpos_str() As String = New String() {"Unknown finger", "Right thumb", "Right index finger", "Right middle finger", "Right ring finger", "Right little finger", "Left thumb", "Left index        finger", "Left middle finger", "Left ring finger", "Left little finger"}
        Dim err As Int32
        Dim finger_pos As SGFPMFingerPosition = SGFPMFingerPosition.FINGPOS_UK
        Dim finger_found As Boolean = False
	'Calling the funtion that filter the template from database
       	 m_StoredTemplate = PopulateTempelates("SELECT Tempelate FROM Biometric")


            Dim sample_info As SGFPMANSITemplateInfo = New SGFPMANSITemplateInfo
            err = Me.m_FPM.GetAnsiTemplateInfo(Me.m_StoredTemplate, sample_info)
            Dim i As Integer = 0
            Do While (i < sample_info.TotalSamples)
                Dim matched As Boolean = False
                err = Me.m_FPM.MatchAnsiTemplate(Me.m_StoredTemplate, i, Me.m_VrfMin, 0, Me.m_SecurityLevel, matched)
                If matched Then
                    finger_found = True
                    finger_pos = CType(sample_info.SampleInfo(i).FingerNumber, SGFPMFingerPosition)
                    Exit Do
                End If




                i = (i + 1)
            Loop




        If (err = SGFPMError.ERROR_NONE) Then
            If finger_found Then
                Me.StatusBar.Text = ("The matched data found. Finger position: " + fingerpos_str(CType(finger_pos, Int32)))
            Else
                Me.StatusBar.Text = "Cannot find a matched data"
            End If
 
Last edited by a moderator:
Hello,
I am very sorry for that , i will take correction next time i am posting code.
Thank you
Dear brother aliyuusman4u, i have same problem, if you resolved the issue, can you sent to me...?

thanks and regards
 
Last edited by a moderator:
Back
Top