Forum Moderators: open

Message Too Old, No Replies

Need help with code

automate title tag

         

webtress

8:10 pm on Aug 23, 2003 (gmt 0)

10+ Year Member



Greeting all,
The site I'm working on uses 1 page to display information from a access database. I would like the page title tag to display the information that is currently being call from the database ie "item_name" automatically and not the default page title. I'm using an inc file and all I seem to get is a blank page or a syntex error. If someone could help me out I would appreiciate it.

on display page:
<title><%=rs("item_name")%></title>

In inc file:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "sDSN"
set rs = Server.CreateObject("ADODB.recordset")
SQL = "SELECT item_name"
rs.Open SQL, conn
do while not rs.EOF
Response.write( rs("item_name") )
rs.MoveNext
loop
rs.close
set rs = nothing

conn.close
set conn = nothing
%>

topr8

8:20 pm on Aug 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you sql statement seems to be incomplete ..

SELECT item_name

should be

SELECT item_name FROM table (and possible contain a WHERE clause too)

topr8

8:25 pm on Aug 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hold on, you are looping through the entire recordset in the include file and then setting rs=nothing

and then you are trying to get a value for rs("item_name") on the page but you have already set rs=nothing

aspdaddy

2:20 pm on Aug 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes you have a few problems with that code

SQL = "SELECT item_name FROM table_name WHERE [Some condition that returns 1 row]"

myVar=rs(0)
rs.close
<title><%=myVar%></title>