S
Suzanne
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
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