473,411 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Problems with FileStreams and images in jpeg format

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
Nov 20 '05 #1
1 1111
Are you getting .jpg and .jpeg mixed up?
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Suzanne | last post by:
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...
3
by: markus | last post by:
I have an application that I think was developed using some form of Borland C with a folder for BIG images with the extension .fre. When I try to view them they cannot be read even by changing the...
18
by: Andrew Christiansen | last post by:
Hey all. The images I create in photoshop with semi-transparent pixels (for instance in Photoshop text with a dropshadow with a transparent canvas) I've been saving in PNG format and then using...
2
by: Suzanne | last post by:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.