I am developing a C# application that has an Access database. What I want to do is allow a user to select an image through an "openfiledialog." I then want to store the image in one of the table of the access database in a BLOB field. I have searched over the internet, but found nothing helpful. I hope you can help me.
enter code here
if (openFileDialog1.ShowDialog() == DialogResult.OK) {
// textBox1.Show(openFileDialog1.FileName.ToString());
//MessageBox.Show(openFileDialog1.FileName.ToString());
textBox1.Text = openFileDialog1.FileName.ToString();
String filename = openFileDialog1.FileName.ToString();
byte[] buffer = File.ReadAllBytes(filename);
using (var conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Policias.accdb"))
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "INSERT INTO DetallesMunicipio(imagen) VALUES (@imagen)";
cmd.Parameters.AddWithValue("@imagen", buffer);
conn.Open();
cmd.ExecuteNonQuery();
}
}
else
{
MessageBox.Show("Porfavor selecciona una imagen");
}
}
but now how can I be sure that is stored in the access database?