473,626 Members | 3,316 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access 97 Images

Bob
I'm looking for an example of how to extract images from an Access 97 blob into an asp datagrid. Anybody have examples?
Nov 20 '05 #1
8 3595
Here's some code extracted from appdev courseware (www.appdev.com)
that was written by Andy Baron, Ken Getz and myself. When you're
working with blobs that originated in Access, you have to strip off
the header info that Access uses for OLE fields. This sample was
designed for a windows form and works with SQLS Northwind, but the
concept is the same -- you have to stream in the data and strip off
those header bytes before you can use the image for anything. I can
probably dig up the VB code from somewhere if you can't figure out the
C#.

--mary

private void LoadEmployeePho to(int employeeID)
{
SqlDataAdapter da = null;
DataTable dt = new DataTable();
string strCnn =
"Data Source=(local); Database=Northw ind;"
+ "Integrated Security=SSPI";
string strSQL =
"SELECT Photo FROM dbo.Employees"
+ " WHERE EmployeeID = "
+ employeeID.ToSt ring();
MemoryStream msPic;
// Signature bytes of an
// OLE container header.
const byte OLEbyte0 = 21;
const byte OLEbyte1 = 28;
// Number of bytes in
// an OLE container header.
const int OLEheaderLength = 78;

da = new SqlDataAdapter( strSQL, strCnn);
da.Fill(dt);
if (dt.Rows.Count == 0)
return;

// Move binary picture data into the byte array
byte[] abytPic = (byte[])dt.Rows[0]["Photo"];

// Test for an OLE container header
if ((abytPic[0] == OLEbyte0)
&& (abytPic[1] == OLEbyte1))
{
// Use a second array to strip off the header.
// Make it big enough to hold
// the bytes after the header.
byte[] abytStripped =
new byte[abytPic.Length - OLEheaderLength];
// Strip off the header by copying the bytes
// after the header.
System.Buffer.B lockCopy(
abytPic, OLEheaderLength , abytStripped,
0, abytPic.Length - OLEheaderLength );

// Load the new byte array
// into a MemoryStream.
msPic = new MemoryStream(ab ytStripped);
}
else
{
// Load the original byte array into a MemoryStream
msPic = new MemoryStream(ab ytPic);
}
// Set the picture box image, using the stream.
picEmployee.Ima ge = Image.FromStrea m(msPic);
}
On Wed, 14 Apr 2004 14:16:06 -0700, Bob <Az*****@cox.ne t> wrote:
I'm looking for an example of how to extract images from an Access 97 blob into an asp datagrid. Anybody have examples?


Nov 20 '05 #2

Mary,

Thanx for your answer. I tried your suggestions and of course can get it
to work with SQL Northwind, but not Access Northwind. I do not believe
images are stored the same in each database. IN SQL "Photo" is an int16,
and there is a column labled PhotoPath which is an nvarchar 255. In
Access there is only a "Photo" column which is an OLE object.
Do you happen to know where I can find the format of the Access OLE
object described?
Again, thank you for taking time to answer my question.
Bob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
Hi Bob,

Are you sure it is in Access97 a blob field and not just a path on disk?

Cor
Nov 20 '05 #4
Let me get back to you on this -- I don't think we ever tested it
against Access directly, so it would be nice to know if the header
fields were of a different size (or whatever). It's basically just
streaming in a bunch of bytes, so the actual storage might be slightly
different between Jet and SQLS.

--mary

On Fri, 16 Apr 2004 13:30:24 -0700, Bob Heath <ro***********@ cox.net>
wrote:

Mary,

Thanx for your answer. I tried your suggestions and of course can get it
to work with SQL Northwind, but not Access Northwind. I do not believe
images are stored the same in each database. IN SQL "Photo" is an int16,
and there is a column labled PhotoPath which is an nvarchar 255. In
Access there is only a "Photo" column which is an OLE object.
Do you happen to know where I can find the format of the Access OLE
object described?
Again, thank you for taking time to answer my question.
Bob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 20 '05 #5
Hi Bob,

Sorry,

Now I see I misreaded it.

I was very happy with that sample from Mary. I made from it in VBnet a
generic blob conversion, sample. And I was happy I had now at last a sample
which could do both (that 21 and 28 does that). However now there seems to
be a thirth format, so I am also curious for that. (Not more than curious).

I made it also workable as a background for an asp datagrid. However what do
you mean with pictures in an asp.datagrid?

Cor
Nov 20 '05 #6
On Fri, 16 Apr 2004 13:30:24 -0700, Bob Heath <ro***********@ cox.net> wrote:

¤
¤ Mary,
¤
¤ Thanx for your answer. I tried your suggestions and of course can get it
¤ to work with SQL Northwind, but not Access Northwind. I do not believe
¤ images are stored the same in each database. IN SQL "Photo" is an int16,
¤ and there is a column labled PhotoPath which is an nvarchar 255. In
¤ Access there is only a "Photo" column which is an OLE object.
¤ Do you happen to know where I can find the format of the Access OLE
¤ object described?
¤ Again, thank you for taking time to answer my question.

There are several factors here that will affect your ability to retrieve this data. First, if it was
stored in an OLE object field, how was it stored? It could have been stored with a databound OLE
control via the native application for the file, or, it could have been stored as *chunks* or a
*stream* of binary bytes. The latter method is the best case scenario.

If it was stored using the OLE control, then the OLE header information (that will need to be
removed) will vary depending upon the file type and application used to store it. This is the worst
case scenario.

Maybe you identify which method was used.
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #7

Paul,

The Access97 Images are from an OLE bound control that I paste gif
images into. Can you point me to when I can figure out how to extract
the gif file?
Thank you for your help.

Bob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #8
On Mon, 19 Apr 2004 14:58:50 -0700, Bob Heath <ro***********@ cox.net> wrote:

¤
¤ Paul,
¤
¤ The Access97 Images are from an OLE bound control that I paste gif
¤ images into. Can you point me to when I can figure out how to extract
¤ the gif file?
¤ Thank you for your help.

I will have to take a look at this. If it's a GIF file then it was probably stored with OLE headers
for Microsoft Photo Editor. If you could take a peek at the contents of the buffer using the code
Mary provided and look for "MSPhotoEd. 3" this would confirm whether Photo Editor was used.

If Photo Editor wasn't used, we would probably need to see first 50 characters or so of the buffer.
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #9

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

Similar topics

4
6783
by: RichG | last post by:
I have an Access database/forms application that has images stored in it. I need to develop a new VB that utilizes Oracle or the file system as the underlying storage for these images. In order to do this I need to retrieve and save the images to disk in their native format. The problem is that the images are stored in Access as the OleObject type rather than binary. I cannot figure out how to pull these imagesfrom the database and...
3
3476
by: Dalan | last post by:
At first I was not certain what could cause Access 97 from displaying most jpeg images, but not all. After further testing, it seemed that all original images of less than 275 pixels per inch or less would display, but those close to 300 pixels/inch or greater would not (MS Access cannot recognize the file format xxx.jpg). The larger, original images were scanned and saved as .bmp (at 300 dpi producing a 15MB file). Then the images were...
4
458
by: bborden | last post by:
I am considering writing a database program that contains text and images with an easy to use interface for my friend's dermatology physician practice. Basically Patient information that links to a database of images containing pictures of the patient's affliction. Is MS Access the best product for this? I did a lot of database programming back in the 80's with a 4th generation database product called Knowledgeman that had a very...
3
4067
by: Bob Dydd | last post by:
Hi Everybody I have an Access 2000 db with a setup for inserting images in records. I am using the image path only with the actual images stored elswhere on the hard disc. This works perfectly well with all of Microsoft developer installed on the system. The problem is when I give this to a user who has NOT got Access 2000, ie I just give him an installation that installs a runtime, my frontend/backend and images, an error says that...
3
7458
by: Alan | last post by:
Hi, I'm converting a database application from Access 97 to C#/SQL Server. Old database contains some images in OLE fields. I've figured out that there's OLE header preceeding actual image data and dealt with some of the images which were in standard BMP format but most of the images are in some other format which is displayed ok in access application and can be copy/pasted to any image editor but when doubleclicking it doesn't open any...
1
3106
by: gm | last post by:
Hi; I have written a database that tracks all the installation we have ever done. I have a small heating company. I have recently started keeping a directory of digital photographs of the completed job. I can create a hyperlink button that will link to a photgraph, but I cannot link to a specific photo of that specific job. Each job has its' own unique identifier, I call it the GOTC number. It is a separate field in the table of installed...
9
3824
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. unfortunately the servers web root www folder only allows READ and EXECUTE permissions, which makes it...
6
3856
by: Bob Alston | last post by:
I am looking for others who have built systems to scan documents, index them and then make them accessible from an Access database. My environment is a nonprofit with about 20-25 case workers who use laptops. They have Access databases on their laptops and the data is replicated. The idea is that each case worker would scan their own documents, either remotely or back at the office. And NO I am not planning to store the scanned...
4
2671
by: redpears007 | last post by:
Hi Again, Throwing this one out to you again as i am not getting anywhere and can find little to no information out there. I am currently displaying images (Jpegs) in access via the routine set up in the article http://support.microsoft.com/kb/285820/en-us. It works fine if the image is under 1000x1000 pixels. It is set up so the user can double click to open the image in its host application.
3
1737
by: anthony | last post by:
I am going to have to start holding jpg files (about 6,000 - 10,000 a year) in our school database. Mainly, they will end up being printed as part of the children's profiles ie via a report. I understand that Access 2007 can hold images without the associated bloat created by previous versions. However, I am reasonably used to Access 2003 and would only want to upgrade if there were significant advantages in the way Access 2007 handles...
0
8272
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8713
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8514
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7206
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6126
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5579
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4094
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1516
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.