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!

Need help with banner rotation script

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi... I wrote this banner script for a friend:


===========================================================
<!--#include file=&quot;adovbs.inc&quot;-->
<%
strConnectionString = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & Server.Mappath(&quot;/mattfest/db/banners.mdb&quot;) & &quot;;&quot;
Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open strConnectionString

sqltemp = &quot;SELECT * FROM Banners&quot;
SET rsTemp = Server.CreateObject(&quot;adodb.Recordset&quot;)
rsTemp.open sqltemp, Conn, adopenstatic


IF Request.Cookies(&quot;banners&quot;)(&quot;adnum&quot;) = &quot;&quot; THEN
CurrentBanner = &quot;1&quot;
ELSE
CurrentBanner = Request.Cookies(&quot;banners&quot;)(&quot;adnum&quot;)
END IF

sqlBanners = &quot;SELECT * FROM Banners WHERE ID = &quot; & CurrentBanner
rsBanners = Conn.Execute(sqlBanners)

Response.Write &quot;<a href=&quot;&quot;&quot; & rsBanners(&quot;URL&quot;) & &quot;&quot;&quot; target=&quot;&quot;_blank&quot;&quot;><img src=&quot;&quot;&quot; & rsBanners(&quot;Image&quot;) & &quot;&quot;&quot; border=&quot;&quot;0&quot;&quot; alt=&quot;&quot;&quot; & rsBanners(&quot;Name&quot;) & &quot;&quot;&quot;></a>&quot;

IF CurrentBanner = TotalBanners THEN
Response.Cookies(&quot;banners&quot;)(&quot;adnum&quot;) = &quot;1&quot;
ELSE
Response.Cookies(&quot;banners&quot;)(&quot;adnum&quot;) = CurrentBanner + 1
END IF

%>


============================================================

It will go through the banner rotation, but when it's done, it gives me this:

ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/mattfest/banners.asp, line 0


I don't know what's wrong... Can you guys help? Thanks in advance!
 
The problem is that your SQL query is returning an empty recordset -- i.e. no record in your database matches the criteria you have specified. Try this on for debugging:

sqlBanners = &quot;SELECT * FROM Banners WHERE ID = &quot; & CurrentBanner

response.write(sqlBanners)

rsBanners = Conn.Execute(sqlBanners)

That way, your sql statement will be written out to the screen before the error is thrown and you can take a look at it to further pinpoint what your problem is. The error will probably be apparent once you do that.

good luck! :)
Paul Prewett
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top