Display Image from database

R

RedSouljaz

Hi,
How to display image that was saved in database ms sql
server 2000 into picture box. The field type that I use
in database is Images

I can save to database but cannot show from database.

Thanks
 
C

Cor Ligthert

Red,

See this snippet. The normal connection, SQL string and sqlcommand and than

\\\
Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader()
rdr.Read()
Dim arrImage() As Byte = DirectCast(rdr.Item("Photo"), Byte())
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Dim ms1 As New System.IO.MemoryStream(arrImage)
'The one above is for normal purpose, however Northwind by instance has a
strange format
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim ms1 As New System.IO.MemoryStream(arrImage, 78, arrImage.Length - 78)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim origimage As System.drawing.Image = System.Drawing.Image.FromStream(ms1)
///

I hope this helps?

Cor
 
H

Herfried K. Wagner [MVP]

RedSouljaz said:
How to display image that was saved in database ms sql
server 2000 into picture box. The field type that I use
in database is Images

If you store the images as a BLOB:

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>
 

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

Top