Wrox Programmer Forums
|
BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003
This is the forum to discuss the Wrox book Professional VB.NET 2003 by Bill Evjen, Billy Hollis, Rockford Lhotka, Tim McCarthy, Jonathan Pinnock, Rama Ramachandran, Bill Sheldon; ISBN: 9780764559921
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2004, 04:19 AM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to display an image type

hi all

i have a problem £¬how to display an image type data from SQLserver

databasse in winform using vb.net .who can tell me a method ,thanks.

 
Old May 23rd, 2004, 08:04 AM
Authorized User
 
Join Date: Jun 2003
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JonathanC
Default


Hi

Although this is possible, it is not recommended.
In your case, would storing the file location and loading it from the file system not be an option?

If not, the data type used in sql, can be Image or Binary.
make sure your column is of this type and create a stored procedure to add entries into the table.
You would have to store the image as a byte array.
ie. (psuedo code below - to give you an idea)

stream = new System.IO.FileStream (yourfile)
byte[] buffer = stream.Read()
'insert into database using stored procedure
sqlcommand = new SqlCommand()
sqlcommand.Parameters.Add("@YourParam", buffer)
sqlcommand.ExecuteNonQuery()

I hope this helps



Jonathan Crossland
http://www.jonathancrossland.com
 
Old May 23rd, 2004, 08:07 AM
Authorized User
 
Join Date: Jun 2003
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JonathanC
Default


To get the image out again.

'Get the byte array back again via a query to database
'create sqlcommand and connection objects
'get the array
byte[] buffer = (byte[])sqlcommand.ExecuteScalar()
'create a stream
memStream = new System.IO.MemoryStream(buffer, true)
myBitmap = new Bitmap(memStream);






Jonathan Crossland
http://www.jonathancrossland.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload image-create & save thumbnail-display image angshujit ASP.NET 2.0 Professional 6 July 11th, 2013 10:34 PM
input type="image" tgopal Javascript How-To 1 September 22nd, 2005 05:16 AM
input type="image" tgopal Javascript 1 September 22nd, 2005 05:15 AM
IMAGE Data type ranakdinesh BOOK: Professional C#, 2nd and 3rd Editions 6 March 18th, 2005 08:35 AM
How to Display the image from the image field. mikeparams SQL Server 2000 1 October 29th, 2004 02:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.