ASP page displaying SQL table data

Discussion in 'ASP General' started by student, Mar 23, 2007.

  1. student

    student Guest

    I am struggling with this asp page. I need to solve this as part of a class
    project. It is designed to simply read a SQL table and display the data in
    the browser. But it will only show one record based on ID at a time. So if I
    have multiple records with the same ID such as page.asp?ID=9734, it would
    show all records using that ID in the browser.

    The result set would display a table with a title header like Guest Name and
    Description

    Below that would be a table with three columns. Reading from left to right
    it would show...

    Program ID Guest Name Guest Description
    9734 Name some description here

    The actual table called T_ProgramGuests has several records with this 4
    digit number but only one shows up in the browser when tested. I need it to
    show all of them but I'm not sure if I should be adding a Loop or IF Then
    Else section to my page. I sure could use some help with the code. See below
    the entire ASP page code.

    Code:
    <%
    set con = Server.CreateObject("ADODB.Connection")
    con.Open "File Name=E:\webservice\Company\Company.UDL"
    set recProgram = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT *, T_ProgramGuests.ProgramID AS Expr1 FROM T_ProgramGuests
    INNER JOIN T_Programs ON T_ProgramGuests.ProgramID = T_Programs.ID WHERE
    (T_ProgramGuests.ProgramID = 9726)"
    
    'strSQL = "SELECT *, T_ProgramGuests.ProgramID AS Expr1 FROM T_ProgramGuests
    INNER JOIN T_Programs ON T_ProgramGuests.ProgramID = T_Programs.ID WHERE
    T_ProgramGuests.ProgramID = & Request("ID")
    
    ' <-- THE BELOW VERSION WORKS. THE ABOVE VERSION KEEPS FAILING -->
    'strSQL = "SELECT *, T_ProgramGuests.ProgramID AS Expr1 FROM T_ProgramGuests
    INNER JOIN T_Programs ON T_ProgramGuests.ProgramID = T_Programs.ID WHERE
    (T_ProgramGuests.ProgramID = 9734)"
    
    
    recProgram.Open strSQL,con
    %>
    
    
    <body>
    <TABLE BORDER="1" CELLPADDING="2" CELLSPACING="1" WIDTH="100%">
    
    <p><b>Guest Name and Description:</b></p>
    <tr>
    <th width="15%" align="left">Program ID</th>
    <th width="35%" align="left">Guest Name</th>
    <th width="55%" align="left">Guest Description</th>
    <tr>
    <TD headers="t1"><%=recProgram.Fields("ProgramID")%></TD>
    <TD headers="t2"><%=recProgram.Fields("GuestName")%></TD>
    <TD headers="t3"><%=recProgram.Fields("GuestDescription")%></TD>
    </tr>
    </table>
    
    <%
    recProgram.Close
    con.Close
    set recProgram = nothing
    set con = nothing
    %>
    
    </body>
    </html>
    
    Any help with this is much appreciated
    --
    Technical School Student
     
    student, Mar 23, 2007
    #1
    1. Advertising

  2. student

    student Guest

    Forgot to mention the SQL server version is 8.0
    --
    Technical School Studen


    "student" wrote:

    > I am struggling with this asp page. I need to solve this as part of a class
    > project. It is designed to simply read a SQL table and display the data in
    > the browser. But it will only show one record based on ID at a time. So if I
    > have multiple records with the same ID such as page.asp?ID=9734, it would
    > show all records using that ID in the browser.
    >
    > The result set would display a table with a title header like Guest Name and
    > Description
    >
    > Below that would be a table with three columns. Reading from left to right
    > it would show...
    >
    > Program ID Guest Name Guest Description
    > 9734 Name some description here
    >
    > The actual table called T_ProgramGuests has several records with this 4
    > digit number but only one shows up in the browser when tested. I need it to
    > show all of them but I'm not sure if I should be adding a Loop or IF Then
    > Else section to my page. I sure could use some help with the code. See below
    > the entire ASP page code.
    >
    >
    Code:
    > <%
    >  set con = Server.CreateObject("ADODB.Connection")
    >  con.Open "File Name=E:\webservice\Company\Company.UDL"
    >  set recProgram = Server.CreateObject("ADODB.Recordset")
    > strSQL = "SELECT *, T_ProgramGuests.ProgramID AS Expr1 FROM T_ProgramGuests
    > INNER JOIN T_Programs ON T_ProgramGuests.ProgramID = T_Programs.ID WHERE
    > (T_ProgramGuests.ProgramID = 9726)"
    >
    > 'strSQL = "SELECT *, T_ProgramGuests.ProgramID AS Expr1 FROM T_ProgramGuests
    > INNER JOIN T_Programs ON T_ProgramGuests.ProgramID = T_Programs.ID WHERE
    > T_ProgramGuests.ProgramID = & Request("ID")
    >
    > ' <-- THE BELOW VERSION WORKS. THE ABOVE VERSION KEEPS FAILING -->
    > 'strSQL = "SELECT *, T_ProgramGuests.ProgramID AS Expr1 FROM T_ProgramGuests
    > INNER JOIN T_Programs ON T_ProgramGuests.ProgramID = T_Programs.ID WHERE
    > (T_ProgramGuests.ProgramID = 9734)"
    >
    >
    > recProgram.Open strSQL,con
    > %>
    >
    >
    > 	<body>
    > 	<TABLE BORDER="1" CELLPADDING="2" CELLSPACING="1" WIDTH="100%">
    >
    > <p><b>Guest Name and Description:</b></p>
    >   <tr>
    >     <th width="15%" align="left">Program ID</th>
    > 		<th width="35%" align="left">Guest Name</th>
    > 		<th width="55%" align="left">Guest Description</th>
    > 	<tr>
    > 		<TD headers="t1"><%=recProgram.Fields("ProgramID")%></TD>
    > 		<TD headers="t2"><%=recProgram.Fields("GuestName")%></TD>
    > 	  <TD headers="t3"><%=recProgram.Fields("GuestDescription")%></TD>
    >   </tr>
    > </table>
    >
    > <%
    > recProgram.Close
    > con.Close
    > set recProgram = nothing
    > set con = nothing
    > %>
    >
    >   </body>
    > </html>
    > 
    >
    > Any help with this is much appreciated
    > --
    > Technical School Student
     
    student, Mar 23, 2007
    #2
    1. Advertising

  3. student

    Jw Vriesman Guest

    See snippet


    "student" <> wrote in message
    news:...
    >I am struggling with this asp page. I need to solve this as part of a class
    > project. It is designed to simply read a SQL table and display the data in
    > the browser. But it will only show one record based on ID at a time. So if
    > I
    > have multiple records with the same ID such as page.asp?ID=9734, it would
    > show all records using that ID in the browser.
    >
    > The result set would display a table with a title header like Guest Name
    > and
    > Description
    >
    > Below that would be a table with three columns. Reading from left to right
    > it would show...
    >
    > Program ID Guest Name Guest Description
    > 9734 Name some description here
    >
    > The actual table called T_ProgramGuests has several records with this 4
    > digit number but only one shows up in the browser when tested. I need it
    > to
    > show all of them but I'm not sure if I should be adding a Loop or IF Then
    > Else section to my page. I sure could use some help with the code. See
    > below
    > the entire ASP page code.
    >
    >
    Code:
    > <%
    > set con = Server.CreateObject("ADODB.Connection")
    > con.Open "File Name=E:\webservice\Company\Company.UDL"
    > set recProgram = Server.CreateObject("ADODB.Recordset")
    > strSQL = "SELECT *, T_ProgramGuests.ProgramID AS Expr1 FROM
    > T_ProgramGuests
    > INNER JOIN T_Programs ON T_ProgramGuests.ProgramID = T_Programs.ID WHERE
    > (T_ProgramGuests.ProgramID = 9726)"
    >
    > 'strSQL = "SELECT *, T_ProgramGuests.ProgramID AS Expr1 FROM
    > T_ProgramGuests
    > INNER JOIN T_Programs ON T_ProgramGuests.ProgramID = T_Programs.ID WHERE
    > T_ProgramGuests.ProgramID = & Request("ID")
    >
    > ' <-- THE BELOW VERSION WORKS. THE ABOVE VERSION KEEPS FAILING -->
    > 'strSQL = "SELECT *, T_ProgramGuests.ProgramID AS Expr1 FROM
    > T_ProgramGuests
    > INNER JOIN T_Programs ON T_ProgramGuests.ProgramID = T_Programs.ID WHERE
    > (T_ProgramGuests.ProgramID = 9734)"
    >
    >
    > recProgram.Open strSQL,con
    > %>
    >
    >
    > <body>
    > <TABLE BORDER="1" CELLPADDING="2" CELLSPACING="1" WIDTH="100%">
    >
    > <p><b>Guest Name and Description:</b></p>
    >  <tr>
    >    <th width="15%" align="left">Program ID</th>
    > <th width="35%" align="left">Guest Name</th>
    > <th width="55%" align="left">Guest Description</th>[/color]
    
    ----------------------------snippet
    <%
    Do while recProgram.eof = false
    %>
    
    [color=blue]
    > <tr>
    > <TD headers="t1"><%=recProgram.Fields("ProgramID")%></TD>
    > <TD headers="t2"><%=recProgram.Fields("GuestName")%></TD>
    >   <TD headers="t3"><%=recProgram.Fields("GuestDescription")%></TD>
    >  </tr>[/color]
    <%
    recProgram.movenext
    loop
    %>
    
    ----------------------------snippet[color=blue]
    > </table>
    >
    > <%
    > recProgram.Close
    > con.Close
    > set recProgram = nothing
    > set con = nothing
    > %>
    >
    >  </body>
    > </html>
    > 
    >
    > Any help with this is much appreciated
    > --
    > Technical School Student
     
    Jw Vriesman, Mar 24, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. .Net Sports

    datagrid not displaying data table data

    .Net Sports, Aug 30, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,791
    .Net Sports
    Aug 31, 2005
  2. =?Utf-8?B?QmVnaW5uZXI=?=
    Replies:
    1
    Views:
    381
    Jeff Dillon
    Apr 21, 2006
  3. Rio
    Replies:
    4
    Views:
    1,220
  4. Yas
    Replies:
    0
    Views:
    493
  5. Renie83
    Replies:
    1
    Views:
    316
    Ray at
    Jul 9, 2003
Loading...

Share This Page