Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display & Update an Access OLE Object (MS Word) using ADO & ASP

Status
Not open for further replies.

LindaH

Programmer
Dec 12, 2001
42
US
I've got an Access database; one of its fields is an OLE Object where the object is an MS Word Document.

I need to display this on an ASP page in a form that can be updated. I can't even get it to display! What am I doing wrong? Here's my code:


<!-- METADATA TYPE=&quot;typelib&quot; FILE=&quot;C:\Program Files\Common Files\System\ado\msado15.dll&quot; -->
<%@ Language=VBScript %>
<%Option Explicit%>

<html>
<head>
<title>Test SQL Image datatype</title>
</head>

<body>

<%
DIM Conn, objRs
Dim strStream
Dim SqlStr, strText

SqlStr =&quot;SELECT * FROM Table1&quot;

Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
set objRs=Server.CreateObject(&quot;ADODB.recordset&quot;)

Conn.ConnectionTimeout=60
Conn.Open &quot;DSN=AccessTest&quot;

objRs.Open SqlStr, Conn, dOpenForwardOnly,adLockReadOnly

Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

Do Until objRs.EOF
Response.write objRs(&quot;Text&quot;)
Response.ContentType = &quot;application/word&quot;
Response.Write objRs(&quot;WordText&quot;)
objRs.MoveNext
Loop

objRs.Close
set objRs=Nothing
Conn.Close
Set Conn=Nothing
%>
</body>
</html>


 
The only way I have been able to display objects is by referring to the location of that object in the WEB site. In other words the Word docs need to be put in a folder on the WEB site and the field in the database is that Word docs location.
Here is an example of viewing images (.jpgs)


<html>
<%@ Language=VBScript%>
<head>
<title>All Cars Live</title>
</head>

<body>

<%
Set fp_conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set fp_rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
fp_conn.Open Application(&quot;Ebay_ConnectionString&quot;)
SQL_String = &quot;Select * From Inventory&quot;
fp_rs.Open SQL_String, fp_conn, 1, 3, 1 ' 2=Table 1=SQL Statement
fp_rs.movelast
fp_rs.movefirst
%>

<p align=&quot;left&quot;><font size=&quot;5&quot;>Pedal Cars, Die Cast Brand, 1:10 Scale</font>
(approx 4&quot; x 2&quot; x 1-1/2&quot; )<br>
Logo-ed as shown Quantity Pricing below

<p align=&quot;left&quot;>click on Any Photo below to <b>Super-<font size=&quot;4&quot;><u>S</u></font></b><u><b><font size=&quot;5&quot;>I</font><font size=&quot;6&quot;>Z</font></b><font size=&quot;7&quot;><b>E</b>
</font></u><font size=&quot;4&quot;>it</font>

<table border=&quot;1&quot; width=&quot;30%&quot;>
<tr>
<td width=&quot;15%&quot;><p align=&quot;center&quot;>Picture</td>
<td width=&quot;8%&quot;>Stock #</td>
<td width=&quot;5%&quot;><p align=&quot;center&quot;>Qty</td>
<td width=&quot;8%&quot;><p align=&quot;center&quot;>Price</td>

</tr>
<%do while not fp_rs.eof%>
<tr>
<td width=&quot;15%&quot;><a href=<%=fp_rs(&quot;PictureBig&quot;)%>> <img border=&quot;2&quot; src=<%=fp_rs(&quot;Picture&quot;)%> alt=&quot;&quot; </a></td>
<td width=&quot;8%&quot;><%=fp_rs(&quot;Partnum&quot;)%> </td>
<td width=&quot;5%&quot;><p align=&quot;center&quot;><%=fp_rs(&quot;QtyInStock&quot;)%> </td>
<td width=&quot;8%&quot;><p align=&quot;right&quot;> <%=FormatCurrency(fp_rs(&quot;Price&quot;))%> </td>

</tr>
<%fp_rs.movenext%>
<%loop%>
<%set fp_conn = nothing%>
<%set fp_rs = nothing%>

</table>

------------------------------------------------------
If you click on a thumbnail it will open a bigger picture


Actual fields and records
------------------------------------------------------

PartNum Description QtyInStock Price Picture PictureBig
PD-101 Pepsi Plane 1 $9.95 pepsiplane_small1.jpg pepsiplane.jpg
PD-102 Fire Truck 2 $9.95 afiretruck_small.jpg afiretruck.jpg
PD-103 Good Humor White 2 $9.95 agoodhum1_small.jpg agoodhum1.jpg
PD-104 Good Humor Tan 1 $9.95 agoodhum2_small.jpg agoodhum2.jpg
PD-105 Pepsi Car Yellow 1 $9.95 apepsicar_small.jpg apepsicar.jpg
PD-106 Pepsi Truck Red/Blue 3 $9.95 apepsitruck_small.jpg apepsitruck.jpg
PD-107 AA Plane Silver 3 $9.95 aaplane_small.jpg aaplane.jpg
PD-108 Police Truck Black 4 $9.95 apolicecar_small.jpg apolicecar.jpg
PD-109 Police Car White 2 $9.95 police1side_small.jpg police1side.jpg
------------------------------------------------------

I learned a long time ago, never embed objects in Access. Just leave them where they lie and call them. The more objects images or what ever you load the bigger the database grows by leaps and bounds. Soon the database will be too big to handle. DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top