Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 1st, 2004, 08:30 PM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default interesting problem - re: database & rollovers

can anybody please help??
this problem is really annoying me.
My website default page includes in loads of other pages.
This include page will not work the way it should.
Scenario:
database is intergogated
pulls out the correct records
database is linked to the correct gifs
what i want to do is have my recordset intergogated and then the relevent records have there gifs displayed with mouseovers.
however the gifs do not display... no error is generated either.
field names are identical.
im at a loss......what the problem??
sorry the code is a bit unaligned (copy and paste!!)

<html>
<%
Dim categoryRS, connect, sqlString

' Open Database Connection
Set connect = Server.CreateObject("ADODB.Connection")
connect.Open "NIStamps"

' Open Recordset
Set categoryRS = Server.CreateObject("ADODB.Recordset")
sqlString = "SELECT * FROM Department ORDER BY DepartmentName"
categoryRS.Open sqlString, connect, adOpenStatic, adLockOptimistic
%>

<body onLoad="MM_preloadImages('<%=categoryRS("Departmen tButtonOver")%>')">
    <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
        <tr>
            <td align="center" valign="middle">
                <table cellpadding="0" cellspacing="0" border="0" width="150">
                    <tr>
                        <td><img src="images/CategoryCategoryTitle.gif"></td>
                    </tr>
                    <%
                        While Not categoryRS.EOF
                    %>
                    <tr>
                        <td><a href="Default.asp?category=<%=Server.URLEncode(cat egoryRS("DepartmentVariable"))%>" target="_top" onClick="MM_nbGroup('down','group1','<%=categoryRS ("DepartmentName")%>','',1)" onMouseOver="MM_nbGroup('over','<%=categoryRS("Dep artmentName")%>','<%=categoryRS("DepartmentButtonO ver")%>[/b]','',1)" onMouseOut="MM_nbGroup('out')"><img name="<%=categoryRS("DepartmentName")%>" src="<%=categoryRS("DepartmentButton")%>" border="0" width="150" height="25" alt="" onload="" title="<%=categoryRS("DepartmentName")%>"></a></td>
                    </tr>
                    <%
                        categoryRS.MoveNext
                        WEND
                        categoryRS.Close
                    %>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>


 
Old March 2nd, 2004, 03:44 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Does <%=categoryRS("DepartmentButton")%> also include /Images or Images? If not, the images are searched for in the current folder. You may need to change it to this:

src="/Images/<%=categoryRS("DepartmentButton")%>"

HtH,

Imar

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 2nd, 2004, 05:34 AM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Thanks for the help;
But the database fields "DepartmentButton" and "DepartmentButtonOver" contain the images as OLE object fields.
So in theory the <%=categoryRS("DepartmentButton")%> should pull the images from the selected fields in the database.
But it doesnt!!!
Any other ideas??
Sorry if i didnt explain myself better before.



 
Old March 2nd, 2004, 05:54 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Right, but that is never going to happen like this. The src attribute of the image tags needs to be a string with an URI pointing to the image. It should not contain the (binary) image itself.

You can do what you want by creating a separate page, called ShowImage.asp for example. Pass this page the name of the image as a param, for instance:

<img src="ShowImage.asp?IMAGENAME=MyImage.gif" />

or

<img src="ShowImage.asp?IMAGEID=" & MyRecordset("ImageID") />

In ShowImage.asp, you can use the IMAGENAME (or an ID of the image in the database) to retrieve the image form the table, and dump it out to the page, by setting the ContentType of the page to an image type, and using Response.BinaryWrite to dump the image.

However, storing images in a database is not really recommended. It's usually much better / faster / easier to store the path of the image in the database, and save the image itself to disk.

Let me know if you need more help with this.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 2nd, 2004, 09:41 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi highbeef,

Thanks for your message. I am glad everything worked out....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Attaching database & DBCC CHECKTABLE problem... seananderson SQL Server 2000 5 April 2nd, 2007 08:29 AM
Interesting Problem prasanta2expert ASP.NET 1.0 and 1.1 Basics 1 October 16th, 2006 08:14 PM
CSS Rollovers Using JScript in IE 6.0 Problem kwilliams Other Programming Languages 1 March 1st, 2006 01:20 PM
Interesting validation problem jacob ASP.NET 1.0 and 1.1 Professional 5 February 16th, 2006 07:16 PM
Interesting Data Type Problem dlandolin SQL Server 2000 3 February 23rd, 2005 06:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.