Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Asp help urgently

Posted on 2004-03-26
6
Medium Priority
?
212 Views
Last Modified: 2011-09-20
dear member,
         I need help in a program of ASP   , in which i have to draw values from two tables (parent and Child) in a tree form and put them in a way that each child record come below its corresponding parent record and next parent record is next in the same row after previous parent record with the same condition as i have told. i have four parent records and each parent record has two child records. i have wrote a code in which i m having some problems this code is giving two record from ist child records and  1 from each later as well as it is also showing one record in child 2 which is actually part of child3.
 sir plz help me i will be very thankful to u.
         i m sending u the code.sir plz remove the error and send me the correct code



<% Option Explicit %>
<html>
<head>
<title>view</title>
</head>
<Body bgcolor="white" >
 
 <%
    dim sql,connect,sql2,i,j,k
      set connect=server.createobject("ADODB.Connection")
      
      connect.open "Hd"
      

      set sql= connect.Execute(_
                 "select dname,ename from dept,emp where dept.deptid=emp.deptid ")%>
 


 <center><h1>ASP Chart</h1></center>
<br><br>
<table bgcolor="#8FA5AB" color="ghostwhite" border="1" cellpadding="0" cellspacing="0" align="center" width="557">
<tr><td><b><center>DG</center><b></td></tr>
</table>      
<br><br><br>

<form name="f1" action="org.asp">
<center>
<table border="1">
<tr>
<%do until sql.eof %>
<%i=1%>    
<td>        
 <b>
          <input type="button" name="b<%=i%>"
value="<%= sql("dname")%>"></b>
<%i=i+1%>
<br><br><br>
<%j=sql("dname")%>

<% while (sql("dname") = j)%>
  <% k=1 %>        
          <input type="button" name="b<%=k%>" value="<%= sql("ename")%>">
            
        <% k=k+1%>    
        <%sql.MoveNext
         wend %>

<br><br><br>
            &nbsp;&nbsp;&nbsp;&nbsp;      
     
</td>      
        <%sql.MoveNext
         loop %>
</tr>
</table>                              
</center>
</form>
                              
                              

                              

</body>
</html>













0
Comment
Question by:leokhan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 500 total points
ID: 10694041

In the while loop you are not displaying the child node...

<% while (sql("dname") = j)%>
  <% k=1 %>        
          <input type="button" name="b<%=k%>" value="<%= sql("ename")%>">
           <%= sql("ename")% '<-------- added
        <% k=k+1%>    
        <%sql.MoveNext
         wend %>

Also, are dnames and ename are order... your logic works only if they are in order in the database...

There are two ways.
1. load all the records into an array and loop through them to get the child nodes directly.
2. for every dname, query the database again for the childnodes... so there will 2 queries.

I hope I am clear...
venkat.
0
 

Author Comment

by:leokhan
ID: 10697380
thanxs for reply.i will try this first and then tell u about it.
      if u can correct the error then correct it by urself i will be more thankful to u.
0
 
LVL 35

Assisted Solution

by:YZlat
YZlat earned 500 total points
ID: 10704121
This should work. I change your sql statement, added a second sql and removed some extra <% and %>

<% Option Explicit %>
<html>
<head>
<title>view</title>
</head>
<Body bgcolor="white" >
 
 <%
    dim sql,connect,sql2,i,j,k
     set connect=server.createobject("ADODB.Connection")
     
     connect.open "Hd"
     

     set sql= connect.Execute(_
                 "select deptid,dname from dept,emp where dept.deptid=emp.deptid order by dname ")%>
 


 <center><h1>ASP Chart</h1></center>
<br><br>
<table bgcolor="#8FA5AB" color="ghostwhite" border="1" cellpadding="0" cellspacing="0" align="center" width="557">
<tr><td><b><center>DG</center><b></td></tr>
</table>    
<br><br><br>

<form name="f1" action="org.asp">
<center>
<table border="1">
<tr>
<%
if not (sql.eof and rs.bof) then
      do while not sql.eof
            i=1  
            %>
            <td>        
             <b>
                      <input type="button" name="<%=i%>"
            value="<%= sql("dname")%>"></b>
            <%i=i+1%>
            <br><br><br>
            <%
            Dim strSQL="select ename from emp,dept where dept.deptid=" & sql("deptid")
             set sql2= connect.Execute(strSQL)
            if not (sql2.eof and sql2.bof) then
             while not sql2.eof
                     k=1 %>        
                            <input type="button" name="b<%=k%>" value="<%= sql2("ename")%>">
           
                          <% k=k+1    
                         sql2.MoveNext
                     Loop %>

            <br><br><br>
                       &nbsp;&nbsp;&nbsp;&nbsp;      
     
            </td>      
        <%sql.MoveNext
         loop
end if
%>
</tr>
</table>                        
</center>
</form>

</body>
</html>

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

618 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