Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi friends.

i have a problem with inserting image in database. my database column type is image and when i want to enter image in database some data restore in database but it is only 13 bytes whereas my images length is 35155 bytes. in my insert command line i placed a break point and i can see that what is i want to save,it's length is correct(35155 bytes) but when i go to (SSMS) i see that only 13 bytes stored in there. or when i want to retrieve data from database i see that what retrieved from database is only 13 bytes. what is wrong?

thank you.
Posted
Comments
Richard Deeming 8-Jan-15 16:05pm    
We can't read your screen, your hard-drive, or your mind. :)

Use the "Improve question" link to update your question with the code you're using to save the image to the database.

You need to use a parameterised statement. There are several articles and tips here on CP that cover it.

Here's one: Load/Unload images into/from DB table[^]
 
Share this answer
 
v2
Comments
_Starbug_ 8-Jan-15 15:39pm    
how can i do this sir.
I would Google for that[^].
 
Share this answer
 
Comments
_Starbug_ 8-Jan-15 15:39pm    
i can store data but it is only 13 bytes.
_Starbug_ 8-Jan-15 15:40pm    
i am using this. do you think this is incorrect way?

System.Drawing.Image imag = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
byte[] Image = null;
Image = new byte[FileUpload1.PostedFile.ContentLength];
HttpPostedFile UploadedImage = FileUpload1.PostedFile;
UploadedImage.InputStream.Read(Image, 0, (int)FileUpload1.PostedFile.ContentLength);
_Starbug_ 8-Jan-15 15:41pm    
after this codes i try to store imag in database. but it is only 13 bytes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900