By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,899 Members | 1,085 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,899 IT Pros & Developers. It's quick & easy.

Unable to Display Image Loaded into SQL Server

P: n/a
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.CloseConnecti on)

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

Dec 16 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Erik Lautier (la*****@gmail.com) writes:
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:
You should probably ask this in a newsgroup devoted to ASP .Net.

And if you ask in an SQL newsgroup, you should include the SQL code you
are using. so we SQL buffs get to see something that we can understand. :-)
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.