Here is a sample of my code where I retrieve a fingerprint template stored in mysql database. I have stored the fingerprint template as BLOB type. I have a table with two fields or columns, CaseFileNumber and FingerP. I have stored the fingerprint template in the FingerP column and also case file number in the CaseFileNumber column When l verify the fingerprint it is able check against the database and verify if it exist or not. My problem is, how can l query the fingerprint to return the CaseFileNumber it is associated with. Here is my sample code below,
Try
Dim max As Integer = 2
cn.Open()
sqlCommand.CommandText = "Select * from ecms.fingerprint"
sqlCommand.CommandType = CommandType.Text
sqlCommand.Connection = cn
Dim lrd As MySqlDataReader = sqlCommand.ExecuteReader()
Dim usr
While lrd.Read()
usr = lrd("FingerP")
End While
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!")
'Me.Hide()
MessageBox.Show("Done")
Else
EventHandlerStatus = Gui.EventHandlerStatus.Failure
MessageBox.Show("Verification failed, User does not exist")
End If
cn.Close()
Finally
cn.Dispose()
End Try
sqlCommand.CommandText = " select CaseFileNumber from ecms.fingerprint where FingerP like %bytes% "
cn.Open()
'Dim arrImage() As Byte
Dim publictable As New DataTable
Try
'cn.Open()
da.SelectCommand = sqlCommand
da.Fill(publictable)
txtcasenumber.Text = publictable.Rows(0).Item(1)
Finally
da.Dispose()
cn.Close()
End Try
It throws me the exception:: An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll but was not handled in user code
Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%bytes%' at line 1 If there is a handler for this exception, the program may be safely continued.
Any suggestions to fix this error is highly appreciated. Thanks