Solved

Show region if recordset is empty

Posted on 2006-06-28
2
333 Views
Last Modified: 2011-09-20
I am creating a Positions Vacant section of a site using Dreamweaver and asp, and the job records are retrieved from an access database.
I need to have a "No Jobs currently listed" message appear when a certain category of positions pulls no records, rather than a blank page.
I am trying to use the "Show region if recordset is empty" facility in Dreamweaver, but I keep getting the message "Before using this behaviour, please create a recordset", although I believe I have. Why is this? Does it matter where I place the "No Jobs Currently listed" message?

This is my asp code on the page:


                        <%
Dim mySQL, mySQLOrder
myDSN = "DBQ=" & Server.MapPath ("positiondatabase.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
mySQL = "SELECT * From [JobDetails] Where [JobIndustryID]= "& Request.QueryString("JobIndustryID")
Select Case Request.QueryString("SortField")
   case "JobDateListed"
      mySQLOrder = " ORDER BY [JobDateListed]desc"
   case "JobTitle"
      mySQLOrder = " ORDER BY [JobTitle]"
   case "JobSuburb"
      mySQLOrder = " ORDER BY [JobSuburb]asc"
   case else
      mySQLOrder = " ORDER BY [JobDateListed]desc"
End Select

Set JobDetailsRS = Server.CreateObject("ADODB.RecordSet")
JobDetailsRS.Open mySQL & mySQLOrder, myDSN
%>
        <%
myDSN = "DBQ=" & Server.MapPath ("positiondatabase.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
mySQL = "SELECT * From [JobIndustry] Where [ID]= "& Request.QueryString("JobIndustryID") & ";"
Set JobIndustryRS = Server.CreateObject("ADODB.RecordSet")
JobIndustryRS.Open mySQL, myDSN
%>

And the fields required to be displayed are placed within the following:

<%Do While Not JobDetailsRS.EOF %>
...........

   <%JobDetailsRS.MoveNext
  Loop%>      
0
Comment
Question by:AndyPaige
2 Comments
 
LVL 22

Accepted Solution

by:
WMIF earned 500 total points
Comment Utility
not sure how dreamweaver handles it, but in asp, you just need to test for records being present.

       <%
myDSN = "DBQ=" & Server.MapPath ("positiondatabase.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
mySQL = "SELECT * From [JobIndustry] Where [ID]= "& Request.QueryString("JobIndustryID") & ";"
Set JobIndustryRS = Server.CreateObject("ADODB.RecordSet")
JobIndustryRS.Open mySQL, myDSN
%>

And the fields required to be displayed are placed within the following:

<%
if JobDetailsRS.EOF then
  ' no records found
  response.write "No Jobs currently listed"
else
  Do While Not JobDetailsRS.EOF %>
...........

   <%JobDetailsRS.MoveNext
  Loop
end if
%>    
0
 

Author Comment

by:AndyPaige
Comment Utility
Thank you WMIF.
Perfect!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now