Forums
This topic is locked
Server behaviour out of order?
Posted 16 Dec 2004 08:05:45
1
has voted
16 Dec 2004 08:05:45 Jens Jakobsen posted:
I'm trying to build a simple asp page where I want to show records from an existing access database. Whenever there is data everything is fine and dandy.Whenever there's an empty row of records I want to apply the "Show if recordset is empty"-behaviour.
But somehow...... this doesn't work.
2 examples - a hand made one and the dreamweaver version:
<b>1: Handmade (this one works):</b>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Set Conn = Server.CreateObject("ADODB.Connection"

Set rsMenu = Server.CreateObject("ADODB.recordset"

conn.open = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\home\franskantikdk\www\_private\franskantik.mdb"
SQLMenu = "SELECT * FROM tblVarer WHERE category='lys';"
conn.Execute (SQLMenu)
rsMenu.Open SQLMenu, conn
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
if rsMenu.bof and rsMenu.eof then
response.Write("No data"

else
if rsMenu("thumbnail"

response.write("No picture"

else
response.Write(rsMenu("thumbnail"

end if
end if
%>
</body>
</html>
<b>2: Dreamweaver - this one doesn't work....</b>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/conn.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset"

Recordset1.ActiveConnection = MM_conn_STRING
Recordset1.Source = "SELECT * FROM tblVarer where category = 'lys';"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
<% If Recordset1.EOF And Recordset1.BOF Then %>
No data
<% End If ' end Recordset1.EOF And Recordset1.BOF %>
</p>
<p><%=(Recordset1.Fields.Item("thumbnail"

</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
What in heavens name am I doing wrong - this seems so simple!!!!
Edited by - fridge on 16 Dec 2004 08:07:40
Edited by - fridge on 16 Dec 2004 08:08:36
Replies
Replied 17 Dec 2004 12:38:33
17 Dec 2004 12:38:33 Lee Diggins replied:
Hi Jens
I can't see anything wrong - I'm deaf in one eye though <img src=../images/dmxzone/forum/icon_smile_blackeye.gif border=0 align=middle>, have you checked the settings in conn.asp?
Digga
Sharing Knowledge Saves Valuable Time!!!
I can't see anything wrong - I'm deaf in one eye though <img src=../images/dmxzone/forum/icon_smile_blackeye.gif border=0 align=middle>, have you checked the settings in conn.asp?
Digga
Sharing Knowledge Saves Valuable Time!!!
Replied 17 Dec 2004 14:55:19
17 Dec 2004 14:55:19 Jens Jakobsen replied:
I can see database and tables as well from the conn properties. All seems OK <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
Replied 17 Dec 2004 15:46:05
17 Dec 2004 15:46:05 Simon Martin replied:
Hi Jens,
Are you saying that if there is no thumbnail image for a given record in your recordset that you want to display no data?
The Show if recordset empty only works if the entire recordset returns no results.
But if you get results back and some of those results do not have a thumbnail then you should stick in an IF ELSE statement
e.g.
<% If Recordset1("thumbnail"
<> "" then %>
<%=(Recordset1.Fields.Item("thumbnail"
.Value)%>
<% Else %>
sorry no picture
<% End if %>
though you could tidy that up / display a default image if you wanted to
HTH
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Are you saying that if there is no thumbnail image for a given record in your recordset that you want to display no data?
The Show if recordset empty only works if the entire recordset returns no results.
But if you get results back and some of those results do not have a thumbnail then you should stick in an IF ELSE statement
e.g.
<% If Recordset1("thumbnail"

<%=(Recordset1.Fields.Item("thumbnail"

<% Else %>
sorry no picture
<% End if %>
though you could tidy that up / display a default image if you wanted to
HTH
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Replied 20 Dec 2004 19:46:15
20 Dec 2004 19:46:15 Jens Jakobsen replied:
That did it - thanks again Simon <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>