Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 15th, 2005, 12:26 AM
Friend of Wrox
 
Join Date: Jun 2003
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





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





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