Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm developing a student fingerprint registration system in vb. I'm using the digital persona u.r.u4500 with the onetouch sdk. I have so far been able to save the fingerprint into mysql and done verification also. What l'm stuck now is how to retrieve the studentID from the database when the fingerprint is verified. This error comes up after verification is complete

An exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll but was not handled in user code Additional information: There is no row at position 0. The error occurs on this line

What I have tried:

As l am able to perform verification.

VB
Private Sub verifyControl_OnComplete(ByVal Control As Object, ByVal FeatureSet As DPFP.FeatureSet, ByRef EventHandlerStatus As DPFP.Gui.EventHandlerStatus) Handles verifyControl.OnComplete

        Try

        cn.Open()
        sqlCommand.CommandText = "Select * from student"
        sqlCommand.CommandType = CommandType.Text
        sqlCommand.Connection = cn
        Dim lrd As MySqlDataReader = sqlCommand.ExecuteReader()

        While lrd.Read()
            usr = lrd("print")

        End While
        lrd.Dispose()
        bytes = Nothing
        bytes = usr
        template = New DPFP.Template()
        template.DeSerialize(usr)
        'Perform match
        matcher.Verify(FeatureSet, template, matchResult)
        If matchResult.Verified Then
            EventHandlerStatus = Gui.EventHandlerStatus.Success

            MessageBox.Show("Verified!, Fingerprint exist in database")
I suspect the fault to be from this block

            sqlCommand.CommandText = " select StudentID from student  where 
            print like '%template%' "

            Dim publictable As New DataTable
            Try

                adapter.SelectCommand = sqlCommand

                adapter.Fill(publictable)
                txtstudentID.Text = publictable.Rows(0).Item(1)
            Finally


                adapter.Dispose()
                cn.Close()
            End Try


I am passing a variable to an mysql statement. Now the variable resides in the code and not the database so querying it will return no results which l am currently getting. Is there a way to use select statement to query mysql to retrieve the studentID associated with the fingerprint template in the database(BLOB).
Posted
Updated 21-Nov-17 20:37pm
v2
Comments
Richard MacCutchan 17-Oct-17 4:26am    
The index out of range indicates that no record was found - something you should always check. And the chances of two fingerprint images being exactly the same is very low. You will most likely need to read each image and do some sort of analysis to check which one is a match. The device documentation should provide information about how to do it.
A_Griffin 19-Oct-17 4:33am    
As Richard says above - no record is found. Also, if all you want is the StudentID then, if this is an Integer, it is somewhat wasteful to read it into a DataTable - a simple ExecuteScalar will read it into an Integer (or Double) variable, though again you should check for Nothing being returned.

1 solution

I suspect that you need a stored procedure to load the data and return the ID of the row that it inserts. Then, you would ExecuteNonQuery, and retrieve the ID into an integer in your VB application. In Microsoft SQL Server, this is the value returned by the Scope_Identity() function. I feel certain that MySQL has something equivalent, although, since I am much more familiar with Microsoft SQL Server than MySQL, I don't know what is the equivalent function. Next, you would do Select * from student where id = InsertResult, where InsertResult is the name of the VB variable that receives the result returned byExecuteNonQuery.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900