Professional Web Applications Themes

Putting query to good use. - ASP Database

Hey folks, hope you all had a good weekend. Here's this mornings dilema for me. I have my query, which when ran in Query yzer, gives me back nice neat little rows with the percentages. "SELECT fit, count(*) * 100.00/ (select count (*) from internal) as [Percent] FROM internal GROUP by fit" gives me... fit Percent -------------------------------------------------- ---------------------------- Agree 20.000000000000 Disagree 20.000000000000 Neither 20.000000000000 StronglyAgree 40.000000000000 (4 row(s) affected) I've constructed my recordset in asp, with the above query. My question is, how do i structure an ASP page to show me the results? Any pointers in the general direction ...

  1. #1

    Default Putting query to good use.

    Hey folks, hope you all had a good weekend. Here's this mornings
    dilema for me.

    I have my query, which when ran in Query yzer, gives me back nice
    neat little rows with the percentages.

    "SELECT fit, count(*) * 100.00/ (select count (*) from internal) as
    [Percent] FROM internal GROUP by fit"

    gives me...

    fit Percent
    --------------------------------------------------
    ----------------------------
    Agree 20.000000000000
    Disagree 20.000000000000
    Neither 20.000000000000
    StronglyAgree 40.000000000000

    (4 row(s) affected)

    I've constructed my recordset in asp, with the above query. My
    question is, how do i structure an ASP page to show me the results?
    Any pointers in the general direction would be much appreciated.

    Thanks for your time gurus!
    nathan Guest

  2. #2

    Default Re: Putting query to good use.

    <table>
    <%
    Dim oADO, oRS, sSQL

    sSQL = "SELECT fit, count(*) * 100.00/ (select count (*) from internal) as
    [Percent] FROM internal GROUP by fit"
    Set oADO = Server.CreateObject("ADODB.Connection")
    oADO.Open YourConnectionString
    Set oRS = oADO.Execute(sSQL)

    Do While Not oRS.EOF
    %>
    <tr>
    <td><%=oRS.Fields.Item(0).Value%></td>
    <td><%=FormatNumber(oRS.Fields.Item(0).Value, 2, -1)%>%</td>
    </tr>
    <%
    oRS.MoveNext
    Loop
    oRS.Close : Set oRS = Nothing
    oADO.Close : Set oADO = Nothing
    %>

    After you get that working, take a look at these articles though.

    [url]http://www.aspfaq.com/2073[/url] (Part about counting)
    [url]http://www.aspfaq.com/2467[/url]

    Also, you could/should make that a stored procedure on your server.

    Ray at work




    "nathan" <n4th4nhushmail.com> wrote in message
    news:908008f8.0310060941.52fdcb77posting.google.c om...
    > Hey folks, hope you all had a good weekend. Here's this mornings
    > dilema for me.
    >
    > I have my query, which when ran in Query yzer, gives me back nice
    > neat little rows with the percentages.
    >
    > "SELECT fit, count(*) * 100.00/ (select count (*) from internal) as
    > [Percent] FROM internal GROUP by fit"
    >
    > gives me...
    >
    > fit Percent
    > --------------------------------------------------
    > ----------------------------
    > Agree 20.000000000000
    > Disagree 20.000000000000
    > Neither 20.000000000000
    > StronglyAgree 40.000000000000
    >
    > (4 row(s) affected)
    >
    > I've constructed my recordset in asp, with the above query. My
    > question is, how do i structure an ASP page to show me the results?
    > Any pointers in the general direction would be much appreciated.
    >
    > Thanks for your time gurus!

    Ray at Guest

  3. #3

    Default Re: Putting query to good use.

    Actually, I would prefer:

    <%
    Dim oADO, oRS, sSQL
    Dim sHTML

    sHTML = "<table><tr><td>"
    sSQL = "SELECT fit, count(*) * 100.00/ (select count (*) from internal) as
    [Percent] FROM internal GROUP by fit"
    Set oADO = Server.CreateObject("ADODB.Connection")
    oADO.Open YourConnectionString
    Set oRS = oADO.Execute(sSQL)
    sHTML = sHTML & oRS.GetString(,,"</td><td>","</td></tr><tr><td>")
    oRS.close
    set oRS = nothing
    oADO.close
    set oADO = nothing
    sHTML = left(sHTML,len(sHTML) - 8) & "</table>"
    %>
    <HTML><HEAD></HEAD><BODY>
    <%=sHTML%>
    </BODY></HTML>

    HTH,
    Bob Barrows



    Ray at <%=sLocation%> wrote:
    > <table>
    > <%
    > Dim oADO, oRS, sSQL
    >
    > sSQL = "SELECT fit, count(*) * 100.00/ (select count (*) from
    > internal) as [Percent] FROM internal GROUP by fit"
    > Set oADO = Server.CreateObject("ADODB.Connection")
    > oADO.Open YourConnectionString
    > Set oRS = oADO.Execute(sSQL)
    >
    > Do While Not oRS.EOF
    > %>
    > <tr>
    > <td><%=oRS.Fields.Item(0).Value%></td>
    > <td><%=FormatNumber(oRS.Fields.Item(0).Value, 2, -1)%>%</td>
    > </tr>
    > <%
    > oRS.MoveNext
    > Loop
    > oRS.Close : Set oRS = Nothing
    > oADO.Close : Set oADO = Nothing
    > %>
    >
    > After you get that working, take a look at these articles though.
    >
    > [url]http://www.aspfaq.com/2073[/url] (Part about counting)
    > [url]http://www.aspfaq.com/2467[/url]
    >
    > Also, you could/should make that a stored procedure on your server.
    >
    > Ray at work
    >
    >
    >
    >
    > "nathan" <n4th4nhushmail.com> wrote in message
    > news:908008f8.0310060941.52fdcb77posting.google.c om...
    >> Hey folks, hope you all had a good weekend. Here's this mornings
    >> dilema for me.
    >>
    >> I have my query, which when ran in Query yzer, gives me back nice
    >> neat little rows with the percentages.
    >>
    >> "SELECT fit, count(*) * 100.00/ (select count (*) from internal) as
    >> [Percent] FROM internal GROUP by fit"
    >>
    >> gives me...
    >>
    >> fit Percent
    >> --------------------------------------------------
    >> ----------------------------
    >> Agree 20.000000000000
    >> Disagree 20.000000000000
    >> Neither 20.000000000000
    >> StronglyAgree 40.000000000000
    >>
    >> (4 row(s) affected)
    >>
    >> I've constructed my recordset in asp, with the above query. My
    >> question is, how do i structure an ASP page to show me the results?
    >> Any pointers in the general direction would be much appreciated.
    >>
    >> Thanks for your time gurus!

    Bob Barrows Guest

  4. #4

    Default Re: Putting query to good use.

    Oops - that was in one of the links - guess I just wasted a few minutes...
    Bob Barrows wrote:
    > Actually, I would prefer:
    >
    <snip>


    Bob Barrows Guest

  5. #5

    Default Re: Putting query to good use.

    Hey, come on now, I provided the links for that method. :] And I thought
    you'd prefer a SP.

    Ray at work

    "Bob Barrows" <reb01501NOyahoo.SPAMcom> wrote in message
    news:%23VltMUDjDHA.2644TK2MSFTNGP10.phx.gbl...
    > Actually, I would prefer:
    >
    > <%
    > Dim oADO, oRS, sSQL
    > Dim sHTML
    >
    > sHTML = "<table><tr><td>"
    > sSQL = "SELECT fit, count(*) * 100.00/ (select count (*) from internal) as
    > [Percent] FROM internal GROUP by fit"
    > Set oADO = Server.CreateObject("ADODB.Connection")
    > oADO.Open YourConnectionString
    > Set oRS = oADO.Execute(sSQL)
    > sHTML = sHTML & oRS.GetString(,,"</td><td>","</td></tr><tr><td>")
    > oRS.close
    > set oRS = nothing
    > oADO.close
    > set oADO = nothing
    > sHTML = left(sHTML,len(sHTML) - 8) & "</table>"
    > %>
    > <HTML><HEAD></HEAD><BODY>
    > <%=sHTML%>
    > </BODY></HTML>
    >
    > HTH,
    > Bob Barrows
    >
    >

    Ray at Guest

  6. #6

    Default Re: Putting query to good use.

    Ray at <%=sLocation%> wrote:
    > ...And I
    > thought you'd prefer a SP.
    >
    Absolutely :-)


    Bob Barrows Guest

  7. #7

    Default Re: Putting query to good use.

    > Also, you could/should make that a stored procedure on your server.

    You can see an incomplete article about that in [url]http://www.aspfaq.com/2201[/url]


    Aaron Bertrand - MVP Guest

  8. #8

    Default Re: Putting query to good use.

    Thanks for the help gentlemen, worked great, and thanks for the articles.
    nathan Guest

Similar Threads

  1. Replies: 9
    Last Post: April 27th, 04:44 AM
  2. Replies: 1
    Last Post: April 7th, 12:55 AM
  3. Replies: 0
    Last Post: March 3rd, 11:31 AM
  4. Putting it all together
    By JohnnySSC webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 0
    Last Post: January 14th, 03:44 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139