J
Jordan Bowness
Can anyone tell me why this doesn't work? It appears to post, but my
..asp page I use to retieve the image pulls up nothing.
Here's the posting snippet:
=======
begin
=======
'\\ turn our posted file into an image:
Dim ourImage As System.Drawing.Image =
System.Drawing.Image.FromStream(imagepost.PostedFile.InputStream)
Dim streamImage As New System.IO.MemoryStream
'\\ read the image into streams then into byte arrays:
ourImage.Save(streamImage,
System.Drawing.Imaging.ImageFormat.Gif)
Dim b(streamImage.Length - 1) As Byte
streamImage.Read(b, 0, streamImage.Length)
Dim sql As String = "INSERT INTO images(imageguid,
imagedata, imagedataThumb) VALUES(newid(),@BlobData,@BlobDataThumb) "
sql = "INSERT INTO images(imageguid, imagedata)
VALUES(newid(),@BlobData) "
Dim parmBlob As New SqlClient.SqlParameter
parmBlob.SqlDbType = SqlDbType.Binary
parmBlob.Value = b
Dim cmd As New SqlClient.SqlCommand(sql, cnn)
cmd.Parameters.Add("@BlobData", SqlDbType.Image)
cmd.Parameters("@BlobData").Value = b
cnn.Open()
cmd.ExecuteNonQuery()
=====
end
=====
and here is the source of the asp page which retrieves the image:
=====
begin
=====
<%
Response.Expires = 0
Response.Buffer = True
Response.Clear
response.ContentType = "image/jpeg"
strImageGUID = getRequest("ImageGUID")
Dim cnn
set cnn = server.createobject("ADODB.Connection")
cnn.Open "Provider=SQLOLEDB;data Source=(local); initial
catalog=ImageDB"
Dim rs
set rs = server.createobject("ADODB.Recordset")
rs.Open "Select * from Images where cast(imageguid as nvarchar(100)) =
'" & strImageGUID & "'", cnn
if rs.eof then response.end
'response.Write "FOUND IT"
response.binarywrite rs.Fields("ImageData").Value
rs.close
cnn.close
%>
<%
function GetRequest(a_RequestName)
dim strTempValue
strTempValue = request.form(a_RequestName)
if len(strTempValue) < 1 then strTempValue =
request.querystring(a_RequestName)
GetRequest = strTempValue
end function
%>
=====
end
=====
Any help would be greatly appreciated!
..asp page I use to retieve the image pulls up nothing.
Here's the posting snippet:
=======
begin
=======
'\\ turn our posted file into an image:
Dim ourImage As System.Drawing.Image =
System.Drawing.Image.FromStream(imagepost.PostedFile.InputStream)
Dim streamImage As New System.IO.MemoryStream
'\\ read the image into streams then into byte arrays:
ourImage.Save(streamImage,
System.Drawing.Imaging.ImageFormat.Gif)
Dim b(streamImage.Length - 1) As Byte
streamImage.Read(b, 0, streamImage.Length)
Dim sql As String = "INSERT INTO images(imageguid,
imagedata, imagedataThumb) VALUES(newid(),@BlobData,@BlobDataThumb) "
sql = "INSERT INTO images(imageguid, imagedata)
VALUES(newid(),@BlobData) "
Dim parmBlob As New SqlClient.SqlParameter
parmBlob.SqlDbType = SqlDbType.Binary
parmBlob.Value = b
Dim cmd As New SqlClient.SqlCommand(sql, cnn)
cmd.Parameters.Add("@BlobData", SqlDbType.Image)
cmd.Parameters("@BlobData").Value = b
cnn.Open()
cmd.ExecuteNonQuery()
=====
end
=====
and here is the source of the asp page which retrieves the image:
=====
begin
=====
<%
Response.Expires = 0
Response.Buffer = True
Response.Clear
response.ContentType = "image/jpeg"
strImageGUID = getRequest("ImageGUID")
Dim cnn
set cnn = server.createobject("ADODB.Connection")
cnn.Open "Provider=SQLOLEDB;data Source=(local); initial
catalog=ImageDB"
Dim rs
set rs = server.createobject("ADODB.Recordset")
rs.Open "Select * from Images where cast(imageguid as nvarchar(100)) =
'" & strImageGUID & "'", cnn
if rs.eof then response.end
'response.Write "FOUND IT"
response.binarywrite rs.Fields("ImageData").Value
rs.close
cnn.close
%>
<%
function GetRequest(a_RequestName)
dim strTempValue
strTempValue = request.form(a_RequestName)
if len(strTempValue) < 1 then strTempValue =
request.querystring(a_RequestName)
GetRequest = strTempValue
end function
%>
=====
end
=====
Any help would be greatly appreciated!