473,382 Members | 1,611 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.

Display DB Image

I have an image stored in a SQL DB how can I display it in a control on a
Windows Form?

TIA!
Nov 21 '05 #1
4 1676
In article <uX**************@TK2MSFTNGP12.phx.gbl>, C CORDON wrote:
I have an image stored in a SQL DB how can I display it in a control on a
Windows Form?

TIA!


Well, I'm not too much of a db expert... But, what you are probably
ending up with is a feild in a dataset that amounts to a byte array -
assuming you are storing the actual image in the database. Once you
have the byte array, displaying that image in a PictureBox is actually
not that difficult... Actually, any setting any controls image
property...

You simply wrap the byte array in a System.IO.MemoryStream object and
call the Image.FromStream method. Here is some sample untested code...

Dim memStream As New MemoryStream (theByteArray)
PictureBox1.Image = Image.FromStream (memStream)

' you probably want to close the stream here...
memStream.Close ()

Anyway, HTH
--
Tom Shelton [MVP]
Nov 21 '05 #2
This link should help:

http://support.microsoft.com/default...b;en-us;326502
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com

"C CORDON" <tc******@hotmail.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
I have an image stored in a SQL DB how can I display it in a control on a
Windows Form?

TIA!

Nov 21 '05 #3
"C CORDON" <tc******@hotmail.com> schrieb:
I have an image stored in a SQL DB how can I display it in a control on a
Windows Form?


HOW TO: Read and Write a File to and from a BLOB Column by Using ADO.NET and
Visual Basic .NET
<URL:http://support.microsoft.com/?scid=kb;EN-US;316887>

HOW TO: Read and Write a File to and from a BLOB Column by Using Chunking in
ADO.NET and Visual Basic .NET
<URL:http://support.microsoft.com/?scid=kb;EN-US;317034>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
I think I forgot to mention I am working on ASP.NET.

I got to the poit of loading the Byte() from the Image field in the table
but donīt know ehre to go from there.

Thanks anyway

:)
"Tom Shelton" <to*@YOUKNOWTHEDRILLmtogden.com> wrote in message
news:eY**************@tk2msftngp13.phx.gbl...
In article <uX**************@TK2MSFTNGP12.phx.gbl>, C CORDON wrote:
I have an image stored in a SQL DB how can I display it in a control on a
Windows Form?

TIA!


Well, I'm not too much of a db expert... But, what you are probably
ending up with is a feild in a dataset that amounts to a byte array -
assuming you are storing the actual image in the database. Once you
have the byte array, displaying that image in a PictureBox is actually
not that difficult... Actually, any setting any controls image
property...

You simply wrap the byte array in a System.IO.MemoryStream object and
call the Image.FromStream method. Here is some sample untested code...

Dim memStream As New MemoryStream (theByteArray)
PictureBox1.Image = Image.FromStream (memStream)

' you probably want to close the stream here...
memStream.Close ()

Anyway, HTH
--
Tom Shelton [MVP]

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tyrone Slothrop | last post by:
I am coding a site which involves uploading images. All of the PHP and display is OK but the client wants to be able to display the image thumbnail on the upload page and show the full image on...
4
by: Kevin Myers | last post by:
Hello, Please forgive my reposting of this note with hopefully a more relevant subject line. On an Access 2000 form under Windows 2000 I would like to use a Kodak Image Edit Control to...
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
4
by: DoomedLung | last post by:
I have been developing an image gallery which needed to be dynamic as possible. so I have placed the gallery in a div plus a div containing the large image to be displayed. It works by changing...
3
by: DoomedLung | last post by:
I have been developing an image gallery which needed to be dynamic as possible. so I have placed the gallery in a div plus a div containing the large image to be displayed. It works by changing...
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...
3
by: c676228 | last post by:
Hi everyone, I have a piece of code in sales.aspx.vb like this: Protected WithEvents Message As System.Web.UI.WebControls.Label Try ... ChartImage.ImageUrl = "ChartGenerator.aspx?" + DataStr +...
0
by: adubra | last post by:
Hi there, I am using a device context (DC) and a buffer to successfully draw to screen. However, when I update the DC at very high frame rate and drag the frame containing the image very quickly...
1
by: nanaalwi | last post by:
Hi, Currently I'm developing a software using VB.net that can grab an image using Matrox Morphis card and display it in a PictureBox. The software can grab the image already and display it in the...
1
by: amritranjan | last post by:
How to retrive image file from MS access database and display this in another JSPpage -------------------------------------------------------------------------------- This is my Jsp code for...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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.