Eduardo luna
Eduardo luna

Reputation: 13

How to Serialize-Deserialize the fingerprint of DigitalPersona u.ere.u 4500 in C# and saved to a database

can you help me? I want to save a fingerprint on mysql, this is the code I use.

private void enrollment_OnEnroll(DPCtlUruNet.EnrollmentControl enrollmentControl, DataResult<Fmd> result, int fingerPosition)
    {
        if (enrollmentControl.Reader != null)
        {
            ShowMessage("OnEnroll:  " + enrollmentControl.Reader.Description.Name + ", finger " + fingerPosition);
        }
        else
        {
            ShowMessage("OnEnroll:  lector no conectado, finger " + fingerPosition);
        }

        if (result != null && result.Data != null)
        {
            //valor de la huella serializada

            string valores = Fmd.SerializeXml(result.Data);
            MySqlConnection conexion = new MySqlConnection(_sender.cadena);
            String sql = String.Format("insert into cliente (clave_cuenta, huella) values('{0}','{1}')", textBox1.Text, valores );
            MySqlCommand comando = new MySqlCommand(sql, conexion);         
            try {
                conexion.Open();
                comando.ExecuteNonQuery();
                conexion.Close();
                MessageBox.Show("La huella se guardo satisfactoriamente","Almacenada",buttons:MessageBoxButtons.OK);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
                throw;
            }
            conexion.Close();
            _sender.Fmds.Add(fingerPosition, result.Data);                

        }

        btnCancel.Enabled = false;

       // _sender.btnApruebaCompra.Enabled = true;
    }

this is stored in mysql

<?xml version="1.0" encoding="UTF-8"?><Fid><Bytes>Rk1SACAyMAAA8gAz/v8AAAFlAYgAxADEAQAAAFYjQIEAZmBkQIEARl5kQMoBKE1jgM8BA0RhgMwAg0tcgNYAZKZcQIIBFB5bgOYA00FaQM8BQFVZQKAAtV9YgLUBEVFYgGUApXNWQOQBIkRUQL0A00RUgPoAckxTQLQAeKVTgG4AcwRTQQMAoKFSQMsA5ptQgMsA65tQQFAAk2xQQREAq0dQgHkA0RhOQEYAoxdCgI8A7Hg/gOEBP00+QFUA4B48gEoAwnQ6QJkA3aA2gJwBAXU2AQMA7UE1AJ0BE2szAQgA7EEuAJwBDqwtAQ4AY6MqAAA=</Bytes><Format>1769473</Format><Version>1.0.0</Version></Fid>

It is supposed FMDs, but I can not return it to its original form.

as return to its normal shape?

Upvotes: 1

Views: 3335

Answers (2)

Akhil Yeluri
Akhil Yeluri

Reputation: 21

In my case using Fmd.DeserializeXml() gave me this error

    '\' is an unexpected token. The expected token is '"' or '''. Line 1, position 15

so i used the following for serialisation and deserialisation respectively

     Fid.SerialiseXml(CaptureResult.data);

     Fid.DeserializeXml(xml string retrieved from db);

Upvotes: 0

jclima05
jclima05

Reputation: 162

string x = Fmd.SerializeXml(fmd);

store x in database as string.

retrieve the string and pass in

Fmd val = Fmd.DeserializeXml(retrieved string from database);

use val to compare to your current input.

Upvotes: 2

Related Questions