I have an image loaded into a picture box and some images saved as BLOB in MySQL. I want to retrieve some data from the row if this image in the picture box is same as the one saved in the database.
There should be only one match and if it doesn't match, should prompt a message as "No match".
I'm using C#, MySQL and Visual Studio.
I don't know how to do this exactly, I'm new to C# and I don't get the output as I want. Maybe I should first convert the IMAGE in the picture box to something else??
Here is what I've come up so far. Any suggestion is highly appreciated.
private void button8_Click(object sender, EventArgs e)
{
// Check button
Image ori_histoImage = histogram_pictureBox.Image;
byte[] histo = (Byte[])new ImageConverter().ConvertTo(ori_histoImage, typeof(byte[]));
string histoS = System.Convert.ToBase64String(histo);
try
{
string MyConnection = "datasource=127.0.0.1;port=3306;username=root;password=;database=ahbis";
string sql = "SELECT * FROM criminal WHERE palmHistogram= '" + histo + "';";
MySqlConnection MyConn = new MySqlConnection(MyConnection);
MySqlCommand MyCommand = new MySqlCommand(sql, MyConn);
int count = Convert.ToInt32(MyCommand.ExecuteScalar());
MySqlDataReader MyReader;
MyConn.Open();
MyReader = MyCommand.ExecuteReader();
while (MyReader.Read())
{
if(count !=1)
{
MessageBox.Show("No match");
string cid = (MyReader["CID"].ToString());
textBox1.Text = cid;
}
else
MessageBox.Show("No match");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}