Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Picture(ref MySqlDataReader myReader, ref MySqlDataAdapter sda)
- {
- try
- {
- string connStr = "server=localhost;user=root;database=читатели;password=12345";
- // создаём объект для подключения к БД
- MySqlConnection conn = new MySqlConnection(connStr);
- // устанавливаем соединение с БД '" + ID + "'
- conn.Open();
- string sql = "SELECT * FROM каталог WHERE Название='" + nameChoiseBook + "'";
- MySqlCommand command = new MySqlCommand(sql, conn);
- myReader = command.ExecuteReader();
- myReader.Read();
- byte[] imgg = (byte[])(myReader["Изображение"]);
- if (imgg == null)
- {
- pictureBox1.Image = null;
- }
- else
- {
- MemoryStream ms = new MemoryStream(imgg);
- pictureBox1.Image = System.Drawing.Image.FromStream(ms);
- }
- conn.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement