I still have a problem displaying images from an access DB using
asp.net. This showimage.aspx is for an admin site.
I need to pull the correct image from the correct table, hence the two
GET variables
I need to re-size the image, while keeping the proper proportions, on
the fly (before it gets to the browser). The images in the DB need to be
full size for the actual web site; thumbnails are only needed in the
admin site, hence the two functions that are included.
Right now I am receiving an error:
Exception Details: System.InvalidCastException: Specified cast is not
valid.
Source Error:
myDataReader.Read()
-> Dim imgStream As System.IO.MemoryStream = myDataReader.Item("Image")
Dim imgbin() As Byte
imgbin = createThumbnail(imgStream, 100, 100)
Response.ContentType="image/jpeg"
Response.BinaryWrite(imgbin)
Problem is, when I set imgStream to:
Dim imgStream As Byte = DirectCast(myDataReader.Item("Image"),Byte)
I get the following error:
Compiler Error Message: BC30311: Value of type 'Byte' cannot be
converted to 'System.IO.Stream'.
Source Error:
myDataReader.Read()
Dim imgStream As Byte = DirectCast(myDataReader.Item("Image"),Byte)
Dim imgbin() As Byte
-> imgbin = createThumbnail(imgStream, 100, 100)
Response.ContentType="image/jpeg"
Response.BinaryWrite(imgbin)
HEEEEELP!!! What could I possibly do to make this work???
TIA
....Geshel
--
************************************************** ********************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
************************************************** ******************** 5 1572
You need to convert the data to a Byte Array before giving assigning it to a
memory stream.
Here's more info: http://SteveOrr.net/articles/EasyUploads.aspx http://SteveOrr.net/articles/ImproveYourImages.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Neo Geshel" <go****@geshel.org> wrote in message
news:uU**************@TK2MSFTNGP14.phx.gbl... I still have a problem displaying images from an access DB using asp.net. This showimage.aspx is for an admin site.
I need to pull the correct image from the correct table, hence the two GET variables
I need to re-size the image, while keeping the proper proportions, on the fly (before it gets to the browser). The images in the DB need to be full size for the actual web site; thumbnails are only needed in the admin site, hence the two functions that are included.
Right now I am receiving an error: Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
myDataReader.Read() -> Dim imgStream As System.IO.MemoryStream = myDataReader.Item("Image") Dim imgbin() As Byte imgbin = createThumbnail(imgStream, 100, 100) Response.ContentType="image/jpeg" Response.BinaryWrite(imgbin)
Problem is, when I set imgStream to:
Dim imgStream As Byte = DirectCast(myDataReader.Item("Image"),Byte)
I get the following error:
Compiler Error Message: BC30311: Value of type 'Byte' cannot be converted to 'System.IO.Stream'.
Source Error:
myDataReader.Read() Dim imgStream As Byte = DirectCast(myDataReader.Item("Image"),Byte) Dim imgbin() As Byte -> imgbin = createThumbnail(imgStream, 100, 100) Response.ContentType="image/jpeg" Response.BinaryWrite(imgbin)
HEEEEELP!!! What could I possibly do to make this work???
TIA ...Geshel -- ************************************************** ******************** My reply-to is an automatically monitored spam honeypot. Do not use it unless you want to be blacklisted by SpamCop. Please reply to my first name at my last name dot org. ************************************************** ********************
Hi,
Here is how to get an image from an access database. The northwind
database has an offset of 78 yours might not have one. Anyway your data
should be stored in an byte array not a memory stream. Hope this helps.
Private Sub ListBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListBox1.SelectedValueChanged
Dim dr As DataRow = ds.Tables("Categories").Rows(ListBox1.SelectedInde x)
Dim ms As New System.IO.MemoryStream
Dim bm As Bitmap
Dim arData() As Byte = dr.Item("Picture")
ms.Write(arData, 78, arData.Length - 78)
bm = New Bitmap(ms)
PictureBox1.Image = bm
End Sub
Ken
-------------------
"Neo Geshel" <go****@geshel.org> wrote in message
news:uU**************@TK2MSFTNGP14.phx.gbl...
I still have a problem displaying images from an access DB using
asp.net. This showimage.aspx is for an admin site.
I need to pull the correct image from the correct table, hence the two
GET variables
I need to re-size the image, while keeping the proper proportions, on
the fly (before it gets to the browser). The images in the DB need to be
full size for the actual web site; thumbnails are only needed in the
admin site, hence the two functions that are included.
Right now I am receiving an error:
Exception Details: System.InvalidCastException: Specified cast is not
valid.
Source Error:
myDataReader.Read()
-> Dim imgStream As System.IO.MemoryStream = myDataReader.Item("Image")
Dim imgbin() As Byte
imgbin = createThumbnail(imgStream, 100, 100)
Response.ContentType="image/jpeg"
Response.BinaryWrite(imgbin)
Problem is, when I set imgStream to:
Dim imgStream As Byte = DirectCast(myDataReader.Item("Image"),Byte)
I get the following error:
Compiler Error Message: BC30311: Value of type 'Byte' cannot be
converted to 'System.IO.Stream'.
Source Error:
myDataReader.Read()
Dim imgStream As Byte = DirectCast(myDataReader.Item("Image"),Byte)
Dim imgbin() As Byte
-> imgbin = createThumbnail(imgStream, 100, 100)
Response.ContentType="image/jpeg"
Response.BinaryWrite(imgbin)
HEEEEELP!!! What could I possibly do to make this work???
TIA
....Geshel
--
************************************************** ********************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
************************************************** ********************
generally a datareader return an image as a byte array. you cannot cast a
byte array to a stream. you must create a stream reader that knows how to
read a byte array, say like the MemoryStream reader.
myDataReader.Read()
Dim imgStream As new MemoryStream(myDataReader.Item("Image"))
imgbin = createThumbnail(imgStream, 100, 100)
Response.ContentType="image/jpeg"
Response.BinaryWrite(imgbin)
-- bruce (sqlwork.com)
"Neo Geshel" <go****@geshel.org> wrote in message
news:uU**************@TK2MSFTNGP14.phx.gbl... I still have a problem displaying images from an access DB using asp.net. This showimage.aspx is for an admin site.
I need to pull the correct image from the correct table, hence the two GET variables
I need to re-size the image, while keeping the proper proportions, on the fly (before it gets to the browser). The images in the DB need to be full size for the actual web site; thumbnails are only needed in the admin site, hence the two functions that are included.
Right now I am receiving an error: Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
myDataReader.Read() -> Dim imgStream As System.IO.MemoryStream = myDataReader.Item("Image") Dim imgbin() As Byte imgbin = createThumbnail(imgStream, 100, 100) Response.ContentType="image/jpeg" Response.BinaryWrite(imgbin)
Problem is, when I set imgStream to:
Dim imgStream As Byte = DirectCast(myDataReader.Item("Image"),Byte)
I get the following error:
Compiler Error Message: BC30311: Value of type 'Byte' cannot be converted to 'System.IO.Stream'.
Source Error:
myDataReader.Read() Dim imgStream As Byte = DirectCast(myDataReader.Item("Image"),Byte) Dim imgbin() As Byte -> imgbin = createThumbnail(imgStream, 100, 100) Response.ContentType="image/jpeg" Response.BinaryWrite(imgbin)
HEEEEELP!!! What could I possibly do to make this work???
TIA ...Geshel -- ************************************************** ******************** My reply-to is an automatically monitored spam honeypot. Do not use it unless you want to be blacklisted by SpamCop. Please reply to my first name at my last name dot org. ************************************************** ********************
Bruce Barker wrote: generally a datareader return an image as a byte array. you cannot cast a byte array to a stream. you must create a stream reader that knows how to read a byte array, say like the MemoryStream reader.
myDataReader.Read() Dim imgStream As new MemoryStream(myDataReader.Item("Image")) imgbin = createThumbnail(imgStream, 100, 100) Response.ContentType="image/jpeg" Response.BinaryWrite(imgbin)
-- bruce (sqlwork.com)
Thanks! Your response was the only one really on-target (the first two
talked about UPLOADS... huh?)
However, I ran into problems when I tried to implement your code:
Error: BC30519: Overload resolution failed because no accessible 'New'
can be called without a narrowing conversion:
Code: Dim imgStream As New MemoryStream(myDataReader.Item("Image"))
Error: BC30638: Array bounds cannot appear in type specifiers.
Code: Dim imgStream As MemoryStream(myDataReader.Item("Image"))
Any suggestions??
TIA
....Geshel
--
************************************************** ********************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
************************************************** ********************
The DataReader.item("xxx") returns a "object" type. Hence it is necessary to
convert it into byte array so that the memory stream can read.
Hope this helps.
"Neo Geshel" wrote: Bruce Barker wrote: generally a datareader return an image as a byte array. you cannot cast a byte array to a stream. you must create a stream reader that knows how to read a byte array, say like the MemoryStream reader.
myDataReader.Read() Dim imgStream As new MemoryStream(myDataReader.Item("Image")) imgbin = createThumbnail(imgStream, 100, 100) Response.ContentType="image/jpeg" Response.BinaryWrite(imgbin)
-- bruce (sqlwork.com)
Thanks! Your response was the only one really on-target (the first two talked about UPLOADS... huh?)
However, I ran into problems when I tried to implement your code:
Error: BC30519: Overload resolution failed because no accessible 'New' can be called without a narrowing conversion: Code: Dim imgStream As New MemoryStream(myDataReader.Item("Image"))
Error: BC30638: Array bounds cannot appear in type specifiers. Code: Dim imgStream As MemoryStream(myDataReader.Item("Image"))
Any suggestions??
TIA ....Geshel -- ************************************************** ******************** My reply-to is an automatically monitored spam honeypot. Do not use it unless you want to be blacklisted by SpamCop. Please reply to my first name at my last name dot org. ************************************************** ******************** This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Simon Harvey |
last post by:
Hi everyone,
Any help with the following would be very greatfully received.
I've been having a lot of problems trying to get the standard winforms
toolbar to display my images correctly. The...
|
by: ZenMaster |
last post by:
Hello, can anyone help me figure out what may be wrong
with my code -
In VC++ 6.0 Ive created a ScrollBar using :
--------------------------------------------
hwndScrollHue = CreateWindowEx...
|
by: Neo Geshel |
last post by:
I still have a problem displaying images from an access DB using
asp.net. This showimage.aspx is for an admin site.
I need to pull the correct image from the correct table, hence the two
GET...
|
by: Thomas Kunnumpurath |
last post by:
Hello all,
I've been scouring the web to try and figure out why this is happening,
but I can't find a solution. I spent four hours last night trying to
fix this problem but to no avail... I am...
|
by: Mark Denardo |
last post by:
This is related to another post I submitted, but I'll be more precise this
time.
I have a web page that contains an Image webcontrol that loads its image by:
Image1.ImageUrl="<username>.jpg",...
| |
by: jalpa11 |
last post by:
Hi all,
I have one EMF image which I want to convert to BMP. I want to scale
the BMP and want to display it in my viewport area. If scaled BMP
doesn't fit inside the viewport area then I want to...
|
by: rpaterso47 |
last post by:
Hello,
I am trying to insert a background image into URLs that link to pages
outside our intranet and thus when clicked open a new window. The
image used is the common one seen on many sites,...
|
by: wsharad |
last post by:
Hi,
I'm new to javascript & trying to achieve a feature for Select Box to incorporate the feature of a textbox also. Like my select box has two events attached, onchange=smeFunction(var1.value) &...
|
by: AramAz |
last post by:
I'm trying to use unsafe mode to do some operations on two different bitmaps.
-I loaded 2 images
-Called my Change method.
- Locked their Bitmap data as bmDataLeft and bmDataRight.
- Doing some...
|
by: LayneMitch via WebmasterKB.com |
last post by:
Hello.
The following code has been shortened just to the main area. It's a form
validation problem. When I hit 'submit', the form is supposed to check if a
selection out of the drop down menu...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |