View Single Post
Join Date: Nov 2008
Posts: 2
Reputation: venkat554 is an unknown quantity at this point 
Solved Threads: 0
venkat554 venkat554 is offline Offline
Newbie Poster

Re: upload images and store the location in a database

 
0
  #5
Dec 4th, 2008
15. Dim connection As New SqlConnection("connection string here")
16. Dim command As New SqlCommand("UPDATE MyTable SET Picture = @Picture WHERE ID = 1", connection)
17.
18. Using picture As Image = Image.FromFile("file path here")
19. Using stream As New IO.MemoryStream
20. picture.Save(stream, Imaging.ImageFormat.Jpeg)
21. command.Parameters.Add("@Picture", SqlDbType.VarBinary).Value = stream.GetBuffer()
22. End Using
23. End Using
24.
25. connection.Open()
26. command.ExecuteNonQuery()
27. connection.Close()
Reply With Quote