0

I searched and tried some codes to save the enrolled fingerprints from the scanner but my error was "id and FP couldn't be null". I know that there is something wrong with the codes i used. I am using OTW SDK of Digital Persona. VB.net as prog.language and MySql as my database. Thank you for helping me solved this problem.

Private Sub btnsave_Click(sender As Object, e As EventArgs) Handles btnsave.Click
    Dim conn As MySqlConnection
    conn = New MySqlConnection
    conn.ConnectionString = ("Server = localhost; User Id= root; Password =1234;Database = dbpayroll")
    Dim cmd As MySqlCommand

    Try
        conn.Open()

        For Each template As DPFP.Template In Data.Templates

            If Not template Is Nothing Then

                cmd = New MySqlCommand("INSERT INTO employeefp " +
                              "SET id=@id, " +
                              "FP=@FP " +
                              " ", conn)

                cmd.Parameters.Add(New MySqlParameter("@id", Me.TextBox1.Text))
                cmd.Parameters.Add(New MySqlParameter("@FP", template.Bytes))

                cmd.ExecuteNonQuery()

                MessageBox.Show("Template Successfuly Saved.", "Finger Enrolled")
            End If
        Next

        conn.Close()
    Catch myerror As MySqlException
        MessageBox.Show(myerror.Message)
    End Try
End Sub
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

0

It seems that nothing is stored in your @id,@FP parameters and you columns in your storage table are declared as NOT NULL.

Try to echo them before insert so you can make sure there is some data passed to them !

Up_One
  • 5,213
  • 3
  • 33
  • 65
  • I tried showing it up using message box before the insert command. first, textbox have data showed up. but same error after. Second thing is when i messagedbox the templates.bytes, I got no data. – user3493393 Apr 03 '14 at 12:03
  • why don't you alter you table definition to accept NULL values and run again, and next see what is stored in the table. – Up_One Apr 03 '14 at 12:52
  • This answers my problem. thank you for helping me out. – user3493393 Apr 03 '14 at 14:41