Click here to Skip to main content
14,641,293 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello, Sorry for my Bad English. Im a student in indonesian SMK which i want to make management system for my school, I used U Are U From Digital Persona for Student Attendance System and i beginner on VB.Net interfacing with Digital Persona U Are U 4500 The problem is, i dont know what the error and i dont know how to Deserialize and Serialize An FMD to MySQL Database. My database datatype is LONGBLOB. I Used this code for serialize

cmd = New MySqlCommand("insert into finger_data(finger) values(@jari)", conn)
With cmd
   .Parameters.AddWithValue("@jari", Fmd.SerializeXml(resultConversion.Data))
   .ExecuteNonQuery()
End With


When i stored the serialize fmd to database is work. And i dont know how to Deserialize.

What I have tried:

I Tried this code for Deserialize fmd from database. And i get this error message "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll

Additional information: There is no row at position 1.

This My Code For Deserialize. I have tried for a long days for this... So Anyone can help me please... Thanks before...

Public Sub OnCaptured(ByVal captureResult As CaptureResult)

        If Not _sender.CheckCaptureResult(captureResult) Then
            Return
        End If

        SendMessage(Action.SendMessage, "The Fingerprint Was Captured")

        Dim resultConversion As DataResult(Of Fmd) = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI)
        If captureResult.ResultCode <> Constants.ResultCode.DP_SUCCESS Then
            _sender.Reset = True
            Throw New Exception(captureResult.ResultCode.ToString())
        End If

        If count = 0 Then

            firstFinger = resultConversion.Data
            count += 1
            SendMessage(Action.SendMessage, "Now place the same or a different finger on the reader.")

        ElseIf count = 1 Then

            secondFinger = resultConversion.Data
            count += 1
            SendMessage(Action.SendMessage, "Now place the same or a different finger on the reader.")

        ElseIf count = 2 Then

            AnyFinger = resultConversion.Data
            Dim fmds As Fmd() = New Fmd(1) {}
            fmds(0) = firstFinger
            fmds(1) = secondFinger

            Dim thresholdScore As Integer = PROBABILITY_ONE * 1 / 10000

            Dim ds As New DataSet
            adt = New MySqlDataAdapter("select * from finger_data where finger", conn)
            adt.Fill(ds, "finger_data")

            Dim A As Integer = ds.Tables("finger_data").Rows(1).Item(0) //I got Error on this Line
            Dim Y As Byte() = DirectCast(ds.Tables("finger_data").Rows(0).Item(2), Byte())
            Dim value As String = System.Text.Encoding.Unicode.GetString(Y)
            Dim X = Fmd.DeserializeXml(value)

            Dim identifyResult As IdentifyResult = Comparison.Identify(X, 0, fmds, thresholdScore, 2)
            If identifyResult.ResultCode <> Constants.ResultCode.DP_SUCCESS Then
                _sender.Reset = True
                Throw New Exception(identifyResult.ResultCode.ToString())
            End If

            SendMessage(Action.SendMessage, "Result Of The Identification " + identifyResult.Indexes.Length.ToString())
            SendMessage(Action.SendMessage, "Place Index")
            count = 0
        End If
    End Sub
Posted
Updated 12-Nov-16 4:25am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 2

The error message is quite clear - you're trying to access the second row of the table, but the table doesn't have two rows. (Remember, the collections are zero-based, so the first row is at index 0.)

Based on the subsequent line, you want to access the first row from the table, so you need to change the row index to 0.

However, you should also check that the query returned a row before you try to access it.
adt.Fill(ds, "finger_data")

If ds.Tables("finger_data").Rows.Count = 0 Then
    ' No rows returned. Show an error message to the user here.
Else
    Dim A As Integer = ds.Tables("finger_data").Rows(0).Item(0)
    ...
End If
   
v2

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100