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> </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> </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
|