944,184 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 44410
  • VB.NET RSS
Jul 22nd, 2007
0

how to save image into database

Expand Post »
what is control that i should use to save image into my database
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Sin Savada is offline Offline
1 posts
since Jul 2007
Jul 23rd, 2007
0

Re: how to save image into database

Reputation Points: 37
Solved Threads: 17
Junior Poster
manal is offline Offline
122 posts
since Mar 2006
Jul 23rd, 2007
0

Re: how to save image into database

Click to Expand / Collapse  Quote originally posted by Sin Savada ...
what is control that i should use to save image into my database
I have attached a small demo project for reading and writing a image in a database. It was developed in VS 2003. Have a look at it and modify it according to your own needs.
Reputation Points: 347
Solved Threads: 13
Practically a Posting Shark
arjunsasidharan is offline Offline
812 posts
since Aug 2006
May 16th, 2008
0

Re: how to save image into database

More on thread
I want information on how to save images into the database and retrive the images into their various picture boxes using visual basic code in windows form.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Ajayi Taiwo O. is offline Offline
2 posts
since May 2008
May 16th, 2008
0

Re: how to save image into database

can you assist me ?
I want to use vb.net to write a code that will save data into an sql server database and retrive it to a picturebox.
thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Ajayi Taiwo O. is offline Offline
2 posts
since May 2008
May 16th, 2008
0

Re: how to save image into database

hi
i think u can't save apicture as apictur in database but u can save the link in database and u can call the picture by acommand or any call sentance


ex
if u save apicture in c:\test\p1.jpg
and
u save this path in database

u can
create acommand to Retriev the path
and change the url of image to the path
like
image.url="path"

i hope help u
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rami2005 is offline Offline
12 posts
since May 2007
Jun 1st, 2008
0

Thanks for you

Really thanks very much for the sample program.i really happy with the program i just learn the SQL server. like these program is very very useful to me.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Rajhumaar is offline Offline
1 posts
since May 2008
Dec 13th, 2010
0
Re: how to save image into database
Reputation Points: 19
Solved Threads: 0
Newbie Poster
lal.ramesh is offline Offline
10 posts
since Nov 2010
Dec 13th, 2010
0
Re: how to save image into database
VB.NET Syntax (Toggle Plain Text)
  1. 'Save an Image to a memory stream so you can get the bytes
  2. Dim sampleImage As Bitmap = New Bitmap(100, 100)
  3. Dim mStream As New System.IO.MemoryStream
  4. Dim ImageBytes As Byte()
  5.  
  6. sampleImage.Save(mStream, Imaging.ImageFormat.Png)
  7. ImageBytes = mStream.ToArray
  8.  
  9. 'Sample Insert image command
  10. 'Save the bytes from the image into a image or varbinary column
  11. Dim com As New SqlClient.SqlCommand("Insert Into MyTable" & vbCrLf & _
  12. "(MyImageColumn)" & vbCrLf & _
  13. "Values(@MyImage)")
  14.  
  15. 'an image column or varbinary column
  16. com.Parameters.Add("@MyImage", SqlDbType.Image)
  17. com.Parameters("@MyImage").Value = ImageBytes
  18.  
  19.  
  20. 'Sample Read Image Command
  21. 'Read the bytes from the table and create a new memory stream from them
  22. com.CommandText = "Select MyImage From MyTable"
  23. Dim rdr As System.Data.SqlClient.SqlDataReader
  24.  
  25. rdr = com.ExecuteReader
  26. If rdr.Read Then
  27. Dim newMstream As New System.IO.MemoryStream(CType(rdr.Item("MyImage"), Byte()))
  28. 'Create a new image from the bytes from the memory
  29. Dim ImageFromDB As New Bitmap(newMstream)
  30.  
  31. End If
Reputation Points: 223
Solved Threads: 192
Posting Pro
Unhnd_Exception is offline Offline
550 posts
since Nov 2010
Dec 14th, 2010
0
Re: how to save image into database
Friends! Do not resurrect old threads. This thread is quite old (3 years).

Thread closed.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in VB.NET Forum Timeline: auto number increment
Next Thread in VB.NET Forum Timeline: Binary Search Tree





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC