As discussed in the last article to Upload Image to MS Access Database you can use OLE Object type field in MS Access Database table to store the byte stream of images sent by ASP.Net code.
Following code can used to stream the image binary stream into the memory stream:
Dim imageType As String
Dim imageStream As Stream
' Gets the Size of the Image
imageSize = fileImgUpload.PostedFile.ContentLength
' Gets the Image Type
imageType = fileImgUpload.PostedFile.ContentType
' Reads the Image stream
imageStream = fileImgUpload.PostedFile.InputStream
Store the InputStream using the above ASP file upload control function into the Stream type variable.
Dim imageContent(imageSize) As Byte
Dim intStatus As Integer
intStatus = imageStream.Read(imageContent, 0, imageSize)
Create the Byte array as in the above code to buffer the image binary stream byte by byte.
To use the stream, you can import the following IO namespace:
You can learn how to load images from Ms Access into the ASP.Net Grid View Control here...
Download the free source code below:
ASP.Net Stream and Display Image from MS Access Database
Be the first to rate this post
Tags: asp.net 2.0, upload image to database, free source code, ms access
8/23/2008 9:05:14 PM