View Full Version : how can i display the data in group heading from 2 table?

08-01-2004, 02:25 AM
this code work
but how can i display the data in group heading of department from 2 table?
asp beginner

<title>display in department group heading</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-874">
<link rel="STYLESHEET" type="text/css" href="style.css">
Set Conndb = Server.createObject("ADODB.Connection")
Conndb.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("/../db/recruit.mdb")
Sql = "SELECT * FROM recruit,Department WHERE recruit.DepartmentID = Department.DepartmentID"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open Sql, Conndb,1,3
<table border=1>
<% Do While Not Rs.Eof %>
<td colspan=2><center><%=Rs("DepartmentT")%></center></td>
<td colspan=2><center><%=Rs("Department.DepartmentID")%></center></td>
<td colspan=2><center><%=Rs("recruit.DepartmentID")%></center></td>
<td ><%=Rs("NameT")%></td>
<td ><%=Rs("qualification")%></td>
Loop %>
set Rs = Nothing%>
Set Conndb = Nothing

08-01-2004, 09:54 AM
what do you mean?

do you want to sort the data by the heading department?

be more precise! :)

08-01-2004, 03:30 PM
i mean that
how to write asp code for displaying the data in group heading of department like this

1.name1a qualification1a
2.name2a qualification2a
3.name3a qualification3a
4.name4a qualification4a
9.name9a qualification9a

1.name1b qualification1b
2.name2b qualification2b
25.name25b qualification25b


Roy Sinclair
08-03-2004, 10:06 PM
What you want to do seems obvious to those of us who were coding on mainframes when paper reports were the preferred medium :D.

You need to declare and initialize (to an empty value) a variable to store the value of the department field. Then inside your loop you check to see if the value of that variable is equal to the value of the department field for the current database record. If they aren't the same (which they won't be the first time through the loop and any time the department changes) you execute code to set the variable to the new value of department and output the department line to your table.

Does this make sense to you?