Good afternoon! I just want to ask if there's wrong with my code here? Especially in the streaming/database saving logic. This saves the same data into the database even if I use different fingerprints, which is (42-4D-2E-06-07-00-00-00-00-00). As I know, the data that is being saved should be different each finger. But even though I try all my fingers, the same data are being inputted into the db. Any help would be much appreciated.
Also, sorry if my question would look confusing, I'm a newbie here and I'm still trying to learn the proper ways. :)
public void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
{
Bitmap bitmap;
bitmap = ConvertSampleToBitmap(Sample);
Bitmap img = new Bitmap(bitmap, Picture.Size);
this.Invoke(new Function(delegate ()
{
Picture.Image = img; // fit the image into the picture box
//string ping;
using (MemoryStream m = new MemoryStream())
{
img.Save(m, ImageFormat.Bmp);
m.Position = 0;
DPFP.Template Template = new DPFP.Template(m);
MemoryStream fingerprintData = new MemoryStream();
Template.Serialize(fingerprintData);
fingerprintData.Position = 0;
BinaryReader br = new BinaryReader(fingerprintData);
Byte[] bytes = br.ReadBytes((Int32)fingerprintData.Length);
string ping = BitConverter.ToString(bytes);
MySqlConnectionStringBuilder connBuilder = new MySqlConnectionStringBuilder();
connBuilder.Add("Server", "localhost");
connBuilder.Add("Port", "3306");
connBuilder.Add("Database", "db_fingerprint");
connBuilder.Add("Username", "root");
connBuilder.Add("Password", "");
MySqlConnection conn = new MySqlConnection(connBuilder.ConnectionString);
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO tbl_finger VALUES(@finger_id, @finger_tag, @stud_id)";
cmd.Parameters.AddWithValue("finger_id", "");
cmd.Parameters.AddWithValue("stud_id", txtstud_num.Text);
cmd.Parameters.AddWithValue("finger_tag", ping);
conn.Open();
int a = cmd.ExecuteNonQuery();
if (a > 0)
{
MessageBox.Show("Fingerprint Registered.");
cmd.CommandText = "UPDATE tbl_students SET is_registered = 1 WHERE stud_id = '" + txtstud_num.Text + "';";
cmd.ExecuteNonQuery();
}
else
{
MessageBox.Show("No Fingerprint Registered.");
}
conn.Close();
}
}));
}