473,480 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

get image data from dataset (insead of directly from db)

I have a slightly different twist on the old question "How do I display
images stored in my database?".

My application does not talk directly to the database. It uses a COM+ dll to
deliver serialized datasets. Then I de-serialize those datasets and work
from those.

All the examples I've seen use a SQL adaptor to stream the data and I can't
quite make that work directly from a dataset. I've tried the following code
but I get a "Specified cast is invalid" when I try to assign a byte array
variable the value from the dataset field (which I see in the debugger is of
a type 'bin.hex'). I also can't seem to get convert.tobyte to work (probably
since it's a byte array). Anyone got any hints for me? Seems like I'm
close, but no cigar.

Dim oRow As DataRow

oRow = oDs.Tables(1).Rows(0)

Dim MyData() As Byte

MyData = oRow.Item("mug_shot") 'this is where I hit the casting error

Response.Buffer = True

Response.ContentType = "Image/JPEG"

Response.BinaryWrite(MyData)
If it matters, these are jpeg images stored as type images in sql server,
but are delivered as strings (serialized datasets). Thanks!

Matt
Nov 18 '05 #1
2 2258
Hi Matt,

Shouldn't that be:

Dim MyData As Byte()

Ken

"MattB" <so********@yahoo.com> wrote in message
news:c7************@ID-86156.news.uni-berlin.de...
I have a slightly different twist on the old question "How do I display
images stored in my database?".

My application does not talk directly to the database. It uses a COM+ dll
to
deliver serialized datasets. Then I de-serialize those datasets and work
from those.

All the examples I've seen use a SQL adaptor to stream the data and I
can't
quite make that work directly from a dataset. I've tried the following
code
but I get a "Specified cast is invalid" when I try to assign a byte array
variable the value from the dataset field (which I see in the debugger is
of
a type 'bin.hex'). I also can't seem to get convert.tobyte to work
(probably
since it's a byte array). Anyone got any hints for me? Seems like I'm
close, but no cigar.

Dim oRow As DataRow

oRow = oDs.Tables(1).Rows(0)

Dim MyData() As Byte

MyData = oRow.Item("mug_shot") 'this is where I hit the casting error

Response.Buffer = True

Response.ContentType = "Image/JPEG"

Response.BinaryWrite(MyData)
If it matters, these are jpeg images stored as type images in sql server,
but are delivered as strings (serialized datasets). Thanks!

Matt


Nov 18 '05 #2
Thanks, I think you are correct, but I still have the problem of the data
being in 'bin.hex'.
Any suggestions or examples for converting the image data from 'bin.hex' to
a bit array?

Matt

Ken Cox [Microsoft MVP] wrote:
Hi Matt,

Shouldn't that be:

Dim MyData As Byte()

Ken

"MattB" <so********@yahoo.com> wrote in message
news:c7************@ID-86156.news.uni-berlin.de...
I have a slightly different twist on the old question "How do I
display images stored in my database?".

My application does not talk directly to the database. It uses a
COM+ dll to
deliver serialized datasets. Then I de-serialize those datasets and
work from those.

All the examples I've seen use a SQL adaptor to stream the data and I
can't
quite make that work directly from a dataset. I've tried the
following code
but I get a "Specified cast is invalid" when I try to assign a byte
array variable the value from the dataset field (which I see in the
debugger is of
a type 'bin.hex'). I also can't seem to get convert.tobyte to work
(probably
since it's a byte array). Anyone got any hints for me? Seems like
I'm close, but no cigar.

Dim oRow As DataRow

oRow = oDs.Tables(1).Rows(0)

Dim MyData() As Byte

MyData = oRow.Item("mug_shot") 'this is where I hit the casting error

Response.Buffer = True

Response.ContentType = "Image/JPEG"

Response.BinaryWrite(MyData)
If it matters, these are jpeg images stored as type images in sql
server, but are delivered as strings (serialized datasets). Thanks!

Matt


Nov 18 '05 #3

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

Similar topics

1
2707
by: Jim | last post by:
I have a very large array of floating point numbers which I am trying to store in an image type field. I am using the dataset class to directly enter the data but am having trouble trying to get...
16
2980
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
0
3720
by: BATISTA | last post by:
Hi , I am working in c# with crystal report XI. I read an example about dynamic image location .. 1) In that we have a xml xchema file with two fields n amed country--datatype is string,...
0
1674
by: BATISTA | last post by:
Hi I have to program in C# such that I have to add a button to the form , and create a crystal report, by getting source from the xml schema file(.xsd file) with two fields namely...
3
1317
by: DwC | last post by:
Hi, We have a ms access database that we will be using to develop a website which would have fairly low usage levels. We have some experience with windows apps but not so much with asp.net...
5
10608
by: moondaddy | last post by:
I'm caching a dataset in an asp.net session variable to hold a user's data. one data item I need to store is an image the user uploaded. My problem is that I don't know how to get the image into...
7
11593
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
3
5348
by: anewbie | last post by:
hi. ive been searching for help with storing images in access. after much hunting i found this bit of code that Cor Ligthert put up on another forum. but when i try to update to the dataset, i...
18
6487
by: Auto | last post by:
Hello, I would like to know how do display an image into a Gridview (ASP.NET 2.0) taken directly from a DataBase, NOT using an URL, like described in this article: ...
0
7041
marktang
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,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6737
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...
0
6921
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4776
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2995
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...
0
1300
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 ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.