Guest User

Untitled

a guest
Jan 19th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. public int Insert(byte[] Byte,string Name,int userid)
  2. {
  3. try
  4. {
  5. SqlCommand storedProcCommand = new SqlCommand("Insert", con);
  6. storedProcCommand.CommandType = CommandType.StoredProcedure;
  7. storedProcCommand.Parameters.AddWithValue("@Bytes", banner2Byte);
  8. storedProcCommand.Parameters.AddWithValue("@name", bannerName);
  9. storedProcCommand.Parameters.AddWithValue("@userid", userid);
  10. con.Open();
  11. storedProcCommand.ExecuteNonQuery();
  12. con.Close();
  13. }
  14. catch (Exception ex)
  15. {
  16. }
  17. }
  18.  
  19. public int Retrieve(int id)
  20. {
  21. try
  22. {
  23. SqlCommand storedProcCommand = new SqlCommand("Retrieve", con);
  24. storedProcCommand.CommandType = CommandType.StoredProcedure;
  25. storedProcCommand.Parameters.AddWithValue("@id", id);
  26. con.Open();
  27. SqlDataReader reader = storedProcCommand.ExecuteReader();
  28. reader.Read();
  29. byte[] arrays= reader.getBytes();
  30. reader.Close();
  31. con.Close();
  32. }
  33. catch (Exception ex)
  34. {
  35. }
  36. }
  37.  
  38. public Image bytearr2image(byte[] byteArrayIn)
  39. {
  40. MemoryStream ms = new MemoryStream(byteArrayIn);
  41. return Image.FromStream(ms);
  42. }
Add Comment
Please, Sign In to add comment