You are here: Unable to Display Image Loaded into SQL Server « MsSQL Server « IT news, forums, messages
Unable to Display Image Loaded into SQL Server

Posted by Erik Lautier on 12/16/06 00:48

Hello, I'm using a multipart/form-data upload to put an image into SQL
Server, and it appears to be working, but I'm unable to display the
image. All I'm getting is the text of the URL we're on in Firefox and
a missing image icon in IE! Any ideas why this isn't working? Here's
the image upload code:

Dim intImageSize As Int64
Dim strImageType As String
Dim ImageStream As Stream

intImageSize = Picture.PostedFile.ContentLength
strImageType = Picture.PostedFile.ContentType

ImageStream = Picture.PostedFile.InputStream

Dim ImageContent(intImageSize) As Byte
Dim intStatus As Integer
intStatus = ImageStream.Read(ImageContent, 0, intImageSize)

'make connection, write SPs, open connection, etc.

Try

dbComm.ExecuteNonQuery()

Connect.close
Catch SQLexc As SqlException
Response.Write("Insert Failed. Error Details are: " &
SQLexc.ToString())
End Try
--------------

And now the display code:

'make connection, then SELECT Image, Imagetype FROM Pets WHERE
[User]=@user AND Petn=@petn
'stored procedures

Dim Reader As SqlDataReader
Reader = dbComm.ExecuteReader(CommandBehavior.CloseConnection)

If Reader.read=True Then
Response.ContentType = Reader(1)
Response.BinaryWrite(Reader(0))
Else
End If
Reader.close
Connect.close
----------------------------
Thanks.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация