473,545 Members | 2,413 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 3592
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
6780
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...
3
3471
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...
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...
3
4061
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...
3
7453
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...
1
3100
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'...
9
3818
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. ...
6
3843
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...
4
2664
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...
3
1729
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...
0
7487
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...
0
7680
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. ...
0
7934
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
4966
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...
0
3476
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...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
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 we have to send another system
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
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...

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.