你能帮助我吗?
我想在mysql上保存一个指纹,这是我使用的代码。

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;
    }

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

它应该是FMDs,但我不能把它还原成原来的形式。
恢复正常的形状?

最佳答案

string x = Fmd.SerializeXml(fmd);

将x作为字符串存储在数据库中。
检索字符串并传入
Fmd val = Fmd.DeserializeXml(从数据库检索到的字符串);
使用val与当前输入进行比较。

08-07 21:29