|
-
Dec 14th, 2007, 06:45 AM
#1
Thread Starter
Lively Member
[2.0] Read and Write images from Database
I want to save an image from a picturebox in the form to the database and read it again from the database to the picturebox. I try to use [PictureBox.Image.Save(<MemoryStream>, PictureBox.Image.RawFormat)] but I got an error. How to do it?
-
Dec 14th, 2007, 07:05 AM
#2
Re: [2.0] Read and Write images from Database
What sort of database is it?
-
Dec 14th, 2007, 07:49 AM
#3
Re: [2.0] Read and Write images from Database
Also, what is the exact code that you are using and what is the error?
-
Dec 15th, 2007, 12:21 PM
#4
Thread Starter
Lively Member
Re: [2.0] Read and Write images from Database
I use SQL database and this is the code I found in VS 2003
Code:
MemoryStream ms = new MemoryStream();
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat);
byte[] arrImage = ms.GetBuffer();
// Close the stream object to release the resource.
ms.Close();
It works good in VS 2003 but the same concept in VS 2005 make an error Message "A generic error occurred in GDI+."
I don't want to make a binding controls to the database but I just want to save the picture from the picturebox to the field image in the database and retrieve it again later.
-
Dec 16th, 2007, 01:47 AM
#5
Re: [2.0] Read and Write images from Database
"PictureBox1.Image.RawFormat"
I've got such problem once
Try using another format, like JPeg or Bmp. I guess that fixed it
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|