Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 15th, 2005, 12:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default Record not found Display Dept name

dated=Request.form("dated")
projno=Request.form("projno")

ssql="select a.projno, e.Name, e.dept,..........
where b.dated='"& dated &"' and a.projno='"& projno &"'"

set rs=cn.Execute(ssql)
if rs.eof=false then

I have to display records base on dated and projno,

1. my problem in dept records. if dept records not found by above
  query, then it should display only dept name
       but is give error, how can control this ?



set cn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")

cn.ConnectionString=" " // connection string
cn.Open


ssql1="select a.projno, e.Name, e.dept,.........
where b.dated='"& DATED &"'
and a.projno='"& projno &"'
and e.dept='"& dept &"'" // problem is here how can move rs("dept") value here
                                    from above query?


ssql2="select a.projno, e.Name, e.dept,.........
where b.dated='"& DATED &"'
and a.projno='"& projno &"'
and e.dept='"& dept &"'" // problem is here how can move rs("dept") value here
                                    from above query?


set rs1=cn.Execute(ssql1)
set rs2=cn.Execute(ssql2)


Response.Write "<tr>"
Response.Write("<td colspan='6'>" & "<strong>" & "" & rs1("dept") & "" & "</strong>" & "</td>")
Response.Write "</tr>"

IF NOT RS.EOF THEN
do while rs.eof=false


Response.Write("<td align=center>" & rs("empno") & "</td>")
Response.Write("<td>" & rs("Name") & "</td>")

totalBH1 = (totalBH1 + cint(rs("BH")))

Response.Write("<td align=center>" & rs("BH") & "</td>")
Response.Write("<td align=center>" & rs("mh1") & "</td>")
....

Response.Write("<td>&nbsp;</td>")

rs.movenext

loop

end if

Response.Write "<tr>"
Response.Write("<td colspan='6'>" & "" & "<strong>" & rs2("dept") & "" & "</strong>" &"</td>")
Response.Write "</tr>"

IF NOT RS2.EOF THEN
do while rs2.eof=false

Response.Write("<td align=center>" & rs2("empno") & "</td>")
Response.Write("<td>" & rs2("Name") & "</td>")

totalBH2 = (totalBH2 + cint(rs2("BH")))

Response.Write("<td align=center>" & rs2("BH") & "</td>")
Response.Write("<td>&nbsp;</td>")


rs2.movenext

loop

end if


else

Response.Redirect("http://dcilweb/tabulation/mhours/DEPTMH.asp?msg=Not+Found")

end if


I have two problem

1. if records found then move rs("dept") value move to e.dept='"& dept &"'" ie.

    ssql1="select a.projno, e.Name, e.dept,.........
    where b.dated='"& DATED &"'
    and a.projno='"& projno &"'
    and e.dept='"& dept &"'"

    and same like also move to rs("dept") value to second query ie.

    ssql2="select a.projno, e.Name, e.dept,.........
    where b.dated='"& DATED &"'
    and a.projno='"& projno &"'
    and e.dept='"& dept &"'"



2. if from the above query (ssql) any one dept have no records
    it shuld display it dept name how ?
    But when dept not found it give error.
    how can control this ?


Please help to solve the above problem.

Regards

Mateen
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating first found record rtr1900 Classic ASP Databases 9 December 2nd, 2005 03:09 AM
how to find record, if not found add in form Sjackson Access 1 May 27th, 2005 10:58 AM
Display 0 when no records found in a query awwhite Access VBA 1 December 2nd, 2004 03:39 PM
No record found eapsokha Classic ASP Databases 1 February 27th, 2004 02:58 AM



All times are GMT -4. The time now is 02:52 PM.


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