PC Review


Reply
Thread Tools Rate Thread

Problems with FileStreams and images in jpeg format

 
 
Suzanne
Guest
Posts: n/a
 
      24th Sep 2003
Hi all,

I'm attempting to save images (that are in jpeg format) to a database
column of type image. I've read over the Microsoft Knowledge Base
articles for this and I can get things working when the image is in a
gif format - but not when the image is in a jpeg format - I get the
error that the file can not be found (& I've checked - the file is
there)!

My code is :
Public Function UpLoadData(ByVal UID As Integer)

Dim dr As SqlDataReader
Dim fs As New FileStream("\\Images\image1.gif", FileMode.Open,
fileAccess.Read)
Dim bytArray(CInt(fs.Length - 1)) As Byte
fs.Read(bytArray, 0, bytArray.Length)
fs.Close()

Dim params() As SqlParameter = {New SqlParameter("@aint_UID",
SqlDbType.Int), _
New SqlParameter("@aimg_Document", SqlDbType.Image,
bytArray.Length)}

params(0).Value = UID
params(1).Value = bytArray

obj_DAL.ExecuteSP("usp_TestImageInsert", params, dr,
DAL.Type.ExecuteNoQuery)
End Function.

Note: obj_DAL is a data access object that opens a sqlconnection and
sets sqlcommand to a stored procedure (this bit works!).

All this code will work as long as the image is in .gif format but not
for .jpeg.

What am I not doing / or doing wrong? When I debug it just gets to
creating the FileStream and then throws the error of the file can not
be found.

Please help!

Thanks
Suzanne
 
Reply With Quote
 
 
 
 
Michael Gray
Guest
Posts: n/a
 
      25th Sep 2003
Are you getting .jpg and .jpeg mixed up?
 
Reply With Quote
 
 
 
 
MSFT
Guest
Posts: n/a
 
      25th Sep 2003
Hi Suzanne,

Are the two files (JIF and JPG) in same folder? Is it possible that you use
a incorrect file name for the JPG file? To make sure this, I suggest you
may check if the file really exists:

for window application:

Msgbox Dir("\\Images\MyJPEG.jpg")

for asp.net application:

Response.wrtie Dir("\\Images\MyJPEG.jpg")

If the file exists, it will display its file name. If not, it will display
a blank string.


Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no

rights.)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
StringReaders and DataWriters and FileStreams, oh, my! Kristian Frost Microsoft VB .NET 2 22nd Sep 2006 08:29 AM
JPEG folder crash Explorer, corrupted JPEG, Nikon vs. Canon JPEG file format?? =?Utf-8?B?YXRsZXRpY28=?= Windows XP Photos 0 17th Feb 2004 04:51 PM
Problems with FileStreams and images in jpeg format Suzanne Microsoft ADO .NET 2 25th Sep 2003 07:53 AM
Problems with FileStreams and images in jpeg format Suzanne Microsoft VB .NET 1 25th Sep 2003 12:08 AM
Re: Filestreams and Compression Jon Skeet Microsoft Dot NET Framework 1 17th Jul 2003 09:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:05 PM.