Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. void Picture(ref MySqlDataReader myReader, ref MySqlDataAdapter sda)
  2. {
  3. try
  4. {
  5. string connStr = "server=localhost;user=root;database=читатели;password=12345";
  6. // создаём объект для подключения к БД
  7. MySqlConnection conn = new MySqlConnection(connStr);
  8. // устанавливаем соединение с БД '" + ID + "'
  9. conn.Open();
  10. string sql = "SELECT * FROM каталог WHERE Название='" + nameChoiseBook + "'";
  11. MySqlCommand command = new MySqlCommand(sql, conn);
  12. myReader = command.ExecuteReader();
  13. myReader.Read();
  14. byte[] imgg = (byte[])(myReader["Изображение"]);
  15. if (imgg == null)
  16. {
  17. pictureBox1.Image = null;
  18. }
  19. else
  20. {
  21. MemoryStream ms = new MemoryStream(imgg);
  22. pictureBox1.Image = System.Drawing.Image.FromStream(ms);
  23. }
  24. conn.Close();
  25. }
  26. catch (Exception ex)
  27. {
  28. MessageBox.Show(ex.Message);
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement