Click here to Skip to main content
15,910,471 members
Home / Discussions / C#
   

C#

 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
JollyMansArt13-Aug-09 6:55
JollyMansArt13-Aug-09 6:55 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
Luc Pattyn13-Aug-09 7:05
sitebuilderLuc Pattyn13-Aug-09 7:05 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. [modified] Pin
JollyMansArt13-Aug-09 7:27
JollyMansArt13-Aug-09 7:27 
AnswerRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
Henry Minute13-Aug-09 7:20
Henry Minute13-Aug-09 7:20 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
JollyMansArt13-Aug-09 8:29
JollyMansArt13-Aug-09 8:29 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
Henry Minute13-Aug-09 8:38
Henry Minute13-Aug-09 8:38 
AnswerRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
JollyMansArt13-Aug-09 7:44
JollyMansArt13-Aug-09 7:44 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
Luc Pattyn13-Aug-09 8:34
sitebuilderLuc Pattyn13-Aug-09 8:34 
Hi,

yes that is very readable now.

disclaimer: I'm not a database specialist, I did some MySQL, a bit of SQL Server,
and no Oracle. I did save and restore images to MySQL once, that worked well.

1.
Assuming your image data will be stored as BLOB, the process indeed is:
- load the file data into a byte array
- construct and execute the SQL command that takes the byte array as a BLOB parameter
(I think your code is off in that aspect)

Suggestion: don't ever show Exception.Message, always show Exception.ToString(),
as it provides much more useful information, including line numbers.
And tell your IDE to always show line numbers in edit windows, see here.[^]
In future posts, please paste the exact exception text and indicate the line that caused it.

Maybe you need to tell the SqlCommand you are adding a BLOB value; so instead of
using AddWithValue, do an Add first (with appropriate DbType), then set the Value
of that new parameter to picByte.

2.
Once storing an image seems to work, I recommend you check your data really got stored in the database by somehow verifying the size of the record; without the image it would be a few dozen bytes; with image it should be thousands (roughly, see file size).

3.
Retrieving an image is almost identical; you don't need to create a file, as there is a Bitmap constructor that takes a byte array.

4.
In general, make Google your friend.
I tried: C# save image to oracle

and found many, maybe you'll like this one.[^]

Hope this helps.

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

QuestionActive X Control... Pin
priyareguri13-Aug-09 6:00
priyareguri13-Aug-09 6:00 
AnswerRe: Active X Control... Pin
Dave Kreskowiak13-Aug-09 7:12
mveDave Kreskowiak13-Aug-09 7:12 
GeneralRe: Active X Control... Pin
priyareguri18-Aug-09 3:21
priyareguri18-Aug-09 3:21 
QuestionGetRelativePath implementation ? Pin
Marc Clifton13-Aug-09 5:54
mvaMarc Clifton13-Aug-09 5:54 
AnswerRe: GetRelativePath implementation ? Pin
Luc Pattyn13-Aug-09 6:52
sitebuilderLuc Pattyn13-Aug-09 6:52 
GeneralRe: GetRelativePath implementation ? Pin
Marc Clifton13-Aug-09 9:18
mvaMarc Clifton13-Aug-09 9:18 
GeneralRe: GetRelativePath implementation ? Pin
Luc Pattyn13-Aug-09 9:48
sitebuilderLuc Pattyn13-Aug-09 9:48 
GeneralRe: GetRelativePath implementation ? [modified] Pin
Scott Dorman13-Aug-09 10:36
professionalScott Dorman13-Aug-09 10:36 
GeneralRe: GetRelativePath implementation ? Pin
Luc Pattyn13-Aug-09 13:26
sitebuilderLuc Pattyn13-Aug-09 13:26 
GeneralRe: GetRelativePath implementation ? Pin
Scott Dorman13-Aug-09 13:48
professionalScott Dorman13-Aug-09 13:48 
AnswerRe: GetRelativePath implementation ? Pin
Scott Dorman13-Aug-09 13:50
professionalScott Dorman13-Aug-09 13:50 
QuestionButton Click event help Pin
spankyleo12313-Aug-09 4:51
spankyleo12313-Aug-09 4:51 
AnswerRe: Button Click event help Pin
stancrm13-Aug-09 4:55
stancrm13-Aug-09 4:55 
GeneralRe: Button Click event help Pin
spankyleo12313-Aug-09 5:15
spankyleo12313-Aug-09 5:15 
QuestionCant find SQL ServerCE.dll Pin
sohaib_a13-Aug-09 4:47
sohaib_a13-Aug-09 4:47 
QuestionProblem in including namespace Pin
Sivaji156513-Aug-09 4:42
Sivaji156513-Aug-09 4:42 
AnswerRe: Problem in including namespace Pin
benjymous13-Aug-09 4:49
benjymous13-Aug-09 4:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.