Error retrieving image from SQL Server, please help

E

Erik Lautier

Hello, I'm using a multipart/form-data upload to put an image into SQL
Server, and it appears to be working (though the Image field in my
table still says "binary"). The upload code is:

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

I'm pretty sure that's working fine, but I can't see the image when I
use this 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top