vbWayne
asked on
thumbnails
I want to store thumbnails of larger pictures in a database so Through ASP I can display the thumbnails when wearching my database.
I know little or nothing about using the ole object in Access.
I set the field type to ole object.
After that I am lost..I tried right clicking in the field and then inserting the picture...when done it says Package.
Seems like a long way to insert a picture and when I call it through ASP by field name I get garbage.
How do I get the pictures inside the database and when calling do I just call the field or do I have to put something on the form to hold the image?
Wayne
I know little or nothing about using the ole object in Access.
I set the field type to ole object.
After that I am lost..I tried right clicking in the field and then inserting the picture...when done it says Package.
Seems like a long way to insert a picture and when I call it through ASP by field name I get garbage.
How do I get the pictures inside the database and when calling do I just call the field or do I have to put something on the form to hold the image?
Wayne
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry vbWayne, my asp is not very good, so bit lost there sorry i should have read that question better
ASKER
No problem!
vbWayne,
I believe all the information you need is in this article. If you wish I can help you implement this in your particular situation, but I'll let you read it first to see if it's an approach you can take.
http://support.microsoft.com/support/kb/articles/q175/2/61.asp
spruce22
I believe all the information you need is in this article. If you wish I can help you implement this in your particular situation, but I'll let you read it first to see if it's an approach you can take.
http://support.microsoft.com/support/kb/articles/q175/2/61.asp
spruce22
ASKER
ok...abit under the weather but I will give it a shot this afternoon..
later
Thanks,
Wayne
later
Thanks,
Wayne
ASKER
Done the demo replacing things with things from my own since I don't have the NW.mdb loaded...
1st. Question
How do I store an image in the access database.
1st. Question
How do I store an image in the access database.
1st. Response.
Programatically or through datasheet view?. Through datasheet view you can just go to windows explorer, right click, copy, go to datasheet view and right click the OLE field and click paste. Adding an image programatically requires a little bit more effort, so let me know if this is acceptable.
Programatically or through datasheet view?. Through datasheet view you can just go to windows explorer, right click, copy, go to datasheet view and right click the OLE field and click paste. Adding an image programatically requires a little bit more effort, so let me know if this is acceptable.
ASKER
Question 2
I'm over my head here.
Ok, now I can add an image...but I still can't get it to show.
Here's what I need.
I have one jpg called chair
I have one jpg called littlechair
I want to display the name Chair with
a link to the jpg Chair....I can do this and I can display via the link...no problem.
Then in column 2 I would like to display the jpg little chair. To do this I need to store the little jpgs in the database under a field called sSmall in a table called Art in an mdb called Art. So I can search the db and list the title and an example of it's contents.
I'll up the points to 100 for working code.....
Wayne
I'm over my head here.
Ok, now I can add an image...but I still can't get it to show.
Here's what I need.
I have one jpg called chair
I have one jpg called littlechair
I want to display the name Chair with
a link to the jpg Chair....I can do this and I can display via the link...no problem.
Then in column 2 I would like to display the jpg little chair. To do this I need to store the little jpgs in the database under a field called sSmall in a table called Art in an mdb called Art. So I can search the db and list the title and an example of it's contents.
I'll up the points to 100 for working code.....
Wayne
Okay,
You said you completed the exapmle with your own stuff, were you able to display a picture that way?
I don't know if you're going to get working code, because the most important part is the ActiveX DLL which you must create, unless somebody sends one to you. The best thing for you will probably be to go through it step by step and analyze your code. If you want, you can email me your ASP files. My email address is under my profile.
spruce22
You said you completed the exapmle with your own stuff, were you able to display a picture that way?
I don't know if you're going to get working code, because the most important part is the ActiveX DLL which you must create, unless somebody sends one to you. The best thing for you will probably be to go through it step by step and analyze your code. If you want, you can email me your ASP files. My email address is under my profile.
spruce22
ASKER
I will do so today.
One ReadMe.txt explaining my attempts
The files related.
Thanks,
Wayne
One ReadMe.txt explaining my attempts
The files related.
Thanks,
Wayne
This is from another question I answered a few months back:
The actual object and raw data associated with it that gets stored in your Access database depends upon whatever object server you have registered to handle the particular file type you're inserting. In my case (on the computer I'm currently working with), Corel Photopaint is registered to handle GIFs and JPGs, so when I embed a GIF or JPG into Access (using insert object), Corel takes over and stores it however it wants to see the data (a CPT file with additional OLE header information). Basically, what I'm saying is that the raw data associated with your object isn't necessarily going to still be a gif or a jpg-- it's going to be decided by whatever server object controls the OLE document.
The easiest way to store images within an Access database is to store the raw data yourself, rather than store the image as an OLE object (with Insert Object). For example, suppose you have the following fields:
TblPictures
PictureID Autonumber
Type Text(10)
Picture OLE
You can insert the raw data into your OLE field with the AppendChuck method. So for example, the following Access function will store an image as a BLOB datatype within the Picture field.
Function addPicture(strFullPath)
Dim rs As Recordset
Dim fileBytes() As Byte
Dim filenum As Integer
ReDim fileBytes(FileLen(strFullP ath))
filenum = FreeFile()
Open strFullPath For Binary As filenum
Get filenum, , fileBytes
Close filenum
Set rs = CurrentDb.OpenRecordset("t blPictures ", dbOpenTable, dbAppendOnly, dbOptimistic)
rs.AddNew
rs("type") = IIf(Right(strFullPath, 3) = "jpg", "jpeg", Right(strFullPath, 3))
rs("picture") = fileBytes
rs.Update
rs.Close
Set rs = Nothing
End Function
You lose the OLE aspect of the object-- you can't double-click it and start up the server application. But, you've now stored the raw data into your field, so you can simply binary write it on your ASP page. If you actually open up tblPictures and look at the data, you'll see that the description of picture says Large Binary Object not Corel Photopaint Image (or whatever you've got registered).
Anyway, I posted a sample that pulls the three images on the page from an Access database-- two are raw images (one gif, one jpg) the other is an OLE BMP image. You can check it out at:
http://experts-exchange.yahright.com/accesspicture/
A zip file containing the database, the asp page, and the html file is at:
http://experts-exchange.yahright.com/accesspicture/accesspicture.zip
The following is the source for the getpicture.asp page which actually pulls the image from the database:
<%
Const OLEHEADERSIZE = 78
strconn = "Provider=Microsoft.Jet.OL EDB.3.51;D ata Source=" & server.mappath(".") & "\picturedb.mdb"
set rs = server.createobject("ADODB .Recordset ")
rs.open "select * from tblPictures where pictureid=" & request.querystring("id"), strconn
if not rs.eof then
select case rs("type")
case "olebmp":
ctype = "image/bmp"
nFieldSize = rs("picture").ActualSize
oleHeader = rs("picture").GetChunk(OLE HEADERSIZE )
imageBytes = rs("picture").GetChunk(nFi eldSize - OLEHEADERSIZE)
case else:
ctype = "image/" & rs("type")
imageBytes = rs("picture")
end select
end if
rs.close
set rs = nothing
response.contenttype = ctype
Response.BinaryWrite imageBytes
%>
The actual object and raw data associated with it that gets stored in your Access database depends upon whatever object server you have registered to handle the particular file type you're inserting. In my case (on the computer I'm currently working with), Corel Photopaint is registered to handle GIFs and JPGs, so when I embed a GIF or JPG into Access (using insert object), Corel takes over and stores it however it wants to see the data (a CPT file with additional OLE header information). Basically, what I'm saying is that the raw data associated with your object isn't necessarily going to still be a gif or a jpg-- it's going to be decided by whatever server object controls the OLE document.
The easiest way to store images within an Access database is to store the raw data yourself, rather than store the image as an OLE object (with Insert Object). For example, suppose you have the following fields:
TblPictures
PictureID Autonumber
Type Text(10)
Picture OLE
You can insert the raw data into your OLE field with the AppendChuck method. So for example, the following Access function will store an image as a BLOB datatype within the Picture field.
Function addPicture(strFullPath)
Dim rs As Recordset
Dim fileBytes() As Byte
Dim filenum As Integer
ReDim fileBytes(FileLen(strFullP
filenum = FreeFile()
Open strFullPath For Binary As filenum
Get filenum, , fileBytes
Close filenum
Set rs = CurrentDb.OpenRecordset("t
rs.AddNew
rs("type") = IIf(Right(strFullPath, 3) = "jpg", "jpeg", Right(strFullPath, 3))
rs("picture") = fileBytes
rs.Update
rs.Close
Set rs = Nothing
End Function
You lose the OLE aspect of the object-- you can't double-click it and start up the server application. But, you've now stored the raw data into your field, so you can simply binary write it on your ASP page. If you actually open up tblPictures and look at the data, you'll see that the description of picture says Large Binary Object not Corel Photopaint Image (or whatever you've got registered).
Anyway, I posted a sample that pulls the three images on the page from an Access database-- two are raw images (one gif, one jpg) the other is an OLE BMP image. You can check it out at:
http://experts-exchange.yahright.com/accesspicture/
A zip file containing the database, the asp page, and the html file is at:
http://experts-exchange.yahright.com/accesspicture/accesspicture.zip
The following is the source for the getpicture.asp page which actually pulls the image from the database:
<%
Const OLEHEADERSIZE = 78
strconn = "Provider=Microsoft.Jet.OL
set rs = server.createobject("ADODB
rs.open "select * from tblPictures where pictureid=" & request.querystring("id"),
if not rs.eof then
select case rs("type")
case "olebmp":
ctype = "image/bmp"
nFieldSize = rs("picture").ActualSize
oleHeader = rs("picture").GetChunk(OLE
imageBytes = rs("picture").GetChunk(nFi
case else:
ctype = "image/" & rs("type")
imageBytes = rs("picture")
end select
end if
rs.close
set rs = nothing
response.contenttype = ctype
Response.BinaryWrite imageBytes
%>
ASKER
spruce22:
Are you still with this or have you decided to pass?
Wayne
Are you still with this or have you decided to pass?
Wayne
ASKER
clockwatcher:
I don't understand how yours works either. I don't know how to use a function in Access and if I put the jpg in using copy, I can't bring it up.
Really, I'm in over my head and the only way I will get this to work is if someone gives me a demo of what I need.
If interested in giving me one it goes like this.
Access mdb with 3 fields
Painting...text field
sSmall....ole
sName...txt
I loop throught the mbd and display
the paintings if search criteria is met.
Let's say I am searching for chair.
I have one jpg called chair
I have one jpg called littlechair
From my search.asp I want to display the name Chair with a link to the jpg (Chair) in left table and in the right table I want to display the jpg (littlechair)
I can display the table with the word chair and the link to the jpg(chair) and I can display the jpg(chair)
What I can't do is display the jpg(littlechair) in the right table.
Someone...if 100 points aren't enough ask for more.
Wayne
<%If Not rsGlobalWeb.BOF Then%>
<div align="center"><center>
<table BORDER="2" width="80%" style="border: medium ridge rgb(0,0,0)" cellspacing="1">
<tr>
<th bgcolor="#FFFFFF" bordercolor="#FF0000" bordercolorlight="#FF0000" bordercolordark="#FF0000"> <p align="center"><img src="images/Title.jpg" width="171" height="34" alt="Title.jpg (2627 bytes)"></th>
<th bgcolor="#FFFFFF" bordercolor="#FF0000" bordercolorlight="#FF0000" bordercolordark="#FF0000"> <p align="center"><img src="images/ArtComments.jp g" width="164" height="34" alt="ArtComments.jpg (2405 bytes)"></th>
</tr>
<%
Do While Not rsGlobalWeb.EOF
%>
<tr>
<td bordercolor="#FF0000" bordercolorlight="#FF0000" bordercolordark="#FF0000"> <p align="left"><a href="#" onclick="showPicture(" ;<%=rsGlob alWeb("Pai nting")%>& quot;);">< %=rsGlobal Web("sName ")%></a></ td>
<td bordercolor="#FF0000" bordercolorlight="#FF0000" bordercolordark="#FF0000"> <% =RsGlobalWeb("sSmall")%>
</td>
</tr>
<% rsGlobalWeb.MoveNext
Loop
%>
</table>
</center></div><%End If%>
<%End If%>
<%
rsGlobalWeb.Close
dbGlobalWeb.Close
%>
I don't understand how yours works either. I don't know how to use a function in Access and if I put the jpg in using copy, I can't bring it up.
Really, I'm in over my head and the only way I will get this to work is if someone gives me a demo of what I need.
If interested in giving me one it goes like this.
Access mdb with 3 fields
Painting...text field
sSmall....ole
sName...txt
I loop throught the mbd and display
the paintings if search criteria is met.
Let's say I am searching for chair.
I have one jpg called chair
I have one jpg called littlechair
From my search.asp I want to display the name Chair with a link to the jpg (Chair) in left table and in the right table I want to display the jpg (littlechair)
I can display the table with the word chair and the link to the jpg(chair) and I can display the jpg(chair)
What I can't do is display the jpg(littlechair) in the right table.
Someone...if 100 points aren't enough ask for more.
Wayne
<%If Not rsGlobalWeb.BOF Then%>
<div align="center"><center>
<table BORDER="2" width="80%" style="border: medium ridge rgb(0,0,0)" cellspacing="1">
<tr>
<th bgcolor="#FFFFFF" bordercolor="#FF0000" bordercolorlight="#FF0000"
<th bgcolor="#FFFFFF" bordercolor="#FF0000" bordercolorlight="#FF0000"
</tr>
<%
Do While Not rsGlobalWeb.EOF
%>
<tr>
<td bordercolor="#FF0000" bordercolorlight="#FF0000"
<td bordercolor="#FF0000" bordercolorlight="#FF0000"
</td>
</tr>
<% rsGlobalWeb.MoveNext
Loop
%>
</table>
</center></div><%End If%>
<%End If%>
<%
rsGlobalWeb.Close
dbGlobalWeb.Close
%>
ASKER
Being as everyone has jumped ship and I cn't figure it out...(not enough experience in some areas), I have decided to do as you have suggested: use the pics outside the db.
Thanks,
Wayne
Thanks,
Wayne
vbWayne,
Sorry, I didn't exactly jump ship. I just didn't have the time or the tools at home to come up with a complete code example. And plus I figured Clockwatcher already had the code on the page to do the job, especially since the example I gave used bitmaps and his was for .jpgs, etc. But you're solution will be fine, and probably even require less programming up front as you won't have to add a part for adding pictures to the database, etc., all you'll have to do is hard code paths to the pictures on the web server. If you've still got questions I'll still be listening:)
Sorry, I didn't exactly jump ship. I just didn't have the time or the tools at home to come up with a complete code example. And plus I figured Clockwatcher already had the code on the page to do the job, especially since the example I gave used bitmaps and his was for .jpgs, etc. But you're solution will be fine, and probably even require less programming up front as you won't have to add a part for adding pictures to the database, etc., all you'll have to do is hard code paths to the pictures on the web server. If you've still got questions I'll still be listening:)
thnaks vbwayne, glad i could help....
ASKER
I do that with the large picture but I want the thumbnails to load next to the hyperlink name.
IE>>>>
Column1 Column2
Picture 1 Name Actual Thumbnail
(sName) (sSmall)
Your code looks live Visual Basic and I need this to work on a WebPage.
Script:
<%
Do While Not rsGlobalWeb.EOF
%>
<tr>
<td><p align="left"><a href="#"
onclick="showPicture("
<%=rsGlobalWeb("sName")%><
<td><a href="#" onClick="showpic("
<%=rsGlobalWeb("sSmall")%>
<% rsGlobalWeb.MoveNext
Loop
%>
So I need to be able to display the picture and not a reference to it. Do you know how I would do that not using the MDB