I am using MySql database and column type is VARBINARY
. I am trying to save template into database. Stored successfully but in database it is storing "System.Byte[]"
but I want to store the binary data. Can you tell why this is displaying in database? is there in code problem or in database problem?
protected override void Process(DPFP.Sample Sample)
{
base.Process(Sample);
DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Enrollment);
DPFP.Capture.SampleConversion ToByte = new DPFP.Capture.SampleConversion();
if (features != null) try
{
MakeReport("The fingerprint feature set was created.");
Enroller.AddFeatures(features);
}
finally
{
UpdateStatus();
// Check if template has been created.
switch (Enroller.TemplateStatus)
{
case DPFP.Processing.Enrollment.Status.Ready: // report success and stop capturing
{
OnTemplate(Enroller.Template);
SetPrompt("Click Close, and then click Fingerprint Verification.");
Stop();
MemoryStream fingerprintData = new MemoryStream();
Enroller.Template.Serialize(fingerprintData);
fingerprintData.Position = 0;
BinaryReader br = new BinaryReader(fingerprintData);
byte[] bytes = br.ReadBytes((Int32)fingerprintData.Length);
try
{
MySqlConnection conn = new MySqlConnection("server=localhost;username=root;password=root;database=enroll");
conn.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
cmd.CommandText = "INSERT INTO reg(reg_temp) VALUES('" + bytes + "')";
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Success!");
}
catch (Exception e)
{
MakeReport(e.Message);
}
break;
}
case DPFP.Processing.Enrollment.Status.Failed: // report failure and restart capturing
{
Enroller.Clear();
Stop();
UpdateStatus();
OnTemplate(null);
Start();
break;
}
}
}
}