When wanting to read from the database with vb.net
it marks me a exception
, apparently because I am bringing data NULL
. I'm new to sql server, this is my code I hope you can help me.
Save the data of a fingerprint in sql server but now when trying to bring them mark the exception the data is saved in varbinary, the field where they are saved is "fp" and when wanting to compare them is when I send the error.
Public Sub OnComplete(Capture As Object, ReaderSerialNumber As String, Sample As Sample) Implements EventHandler.OnComplete
ponerImagen(ConvertirSampleaMapadeBits(Sample))
Dim caracteristicas As DPFP.FeatureSet = extraerCaracteristicas(Sample, DPFP.Processing.DataPurpose.Verification)
If Not caracteristicas Is Nothing Then
Dim result As New DPFP.Verification.Verification.Result()
Dim sqlCon As New SqlConnection(connectionString:=My.Settings.cnn)
sqlCon.Open()
Dim cmd As New SqlCommand()
cmd = sqlCon.CreateCommand
cmd.CommandText = "SELECT * FROM cre_fp"
Dim read As SqlDataReader
read = cmd.ExecuteReader()
Dim verificado As Boolean = False
Dim cuenta As String = ""
While (read.Read())
Dim memoria As New MemoryStream(CType(read("fp"), Byte()))
template.DeSerialize(memoria.ToArray())
verificador.Verify(caracteristicas, template, result)
If (result.Verified) Then
cuenta = ("cuenta")
verificado = True
Exit While
End If
End While
If (verificado) Then
MessageBox.Show(cuenta)
Else
MessageBox.Show("No se ha encontrado al cliente en la base de datos")
End If
read.Dispose()
cmd.Dispose()
sqlCon.Close()
sqlCon.Dispose()
End If
End Sub