473,382 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Unable to Display Image Loaded into SQL Server

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
1 2338
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
7
by: stephcsh | last post by:
Hi, My application is working fine on server A, which is using PHP 4.4.1. However, after it is copied over to server B, which is using PHP 4.4.6, I got several problems related to pdf and xml. ...
2
by: Tim Streater | last post by:
The following test page is intended to allow the user to choose an image file, and then display it. It works as expected in Safari 3.1.1, FF 2.0.0.14 (Mac), and IE7 (XP). But, it fails in FF...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.