Answer the question
In order to leave comments, you need to log in
The following shows how to display a picture from a blob field in a PictureBox, how can I make it so that I can display the same picture in a WebBrowser?
MySqlConnection conn = new MySqlConnection("SERVER=localhost; DATABASE=test ;UID=root;PASSWORD=12345");
MySqlCommand command;
private void button4_Click(object sender, EventArgs e)
{
try
{
string sql = "SELECT fn,ln,file FROM test2 WHERE id=" + textBox1.Text + "";
if (conn.State != ConnectionState.Open)
conn.Open();
command = new MySqlCommand(sql, conn);
MySqlDataReader reader = command.ExecuteReader();
reader.Read();
if (reader.HasRows)
{
textBox2.Text = reader[0].ToString();
textBox3.Text = reader[1].ToString();
byte[] img = (byte[])(reader[2]);
if (img == null)
pictureBox1.Image = null;
else
{
MemoryStream ms = new MemoryStream(img);
pictureBox1.Image = Image.FromStream(ms);
}
}
else
{
MessageBox.Show("Статья не существует");
}
conn.Close();
}
catch (Exception ex)
{
conn.Close();
MessageBox.Show(ex.Message);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question