Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Display the query details in ASP page

    Hi ,

    I am using classic ASP code.

    But i want to display the query result in page.

    query is :strSQL1="select name from v$database"
    dbOA.ExecuteSQL (strSQL1)
    I want to display the query result in page.

    How can i pick those values and display in page.

    please help me on this.

    Thanks,
    Ashok
    Last edited by ashok-n; 06-20-2013 at 01:46 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,566
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    I don't think it is likely that your SQL query is correct:
    Code:
    select name from v$database
    The word after the from keyword must be the name of a TABLE in the database that your dbOA is connected to.
    And I don't know of any databases that allow a $ in the name of a table.

    So here is a *GENERAL* answer that you will have to adapt to your specific table and fields:
    Code:
    <!DOCTYPE html>
    <html>
    <body>
    <table border="1" cellpadding="3">
    <%
    Set dbOA = Server.CreateObject("ADODB.COnnection")
    dbOA.Open "...your connection string..."
    strSQL1 = "SELECT * FROM sometableInYourDatabase"
    Set RS = dbOA.ExecuteSQL (strSQL1)
    ' write the names of all the fields at top of table:
    Response.Write "<tr>" & vbNewLine
    For f = 0 To RS.Fields.Count - 1 
        Response.Write "<th>" & RS.Fields(f).Name & "</th>" & vbNewLine
    Next
    Response.Write "</tr>" & vbNewLine
    ' now dump out the table:
    Do Until RS.EOF
        Response.Write "<tr>" & vbNewLine
        For f = 0 To RS.Fields.Count - 1 
            Response.Write "<td>" & RS.Fields(f).Value & "</td>" & vbNewLine
        Next
        Response.Write "</tr>" & vbNewLine
        RS.MoveNext
    
    Loop
    RS.Close
    dbOA.Close 
    %>
    </table>
    </body>
    </html>
    In place of SELECT * you can use SELECT list,of,field,names where you choose the field names you want to see.
    Last edited by Old Pedant; 06-20-2013 at 08:30 PM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •