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