Select and display

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Help Please

    Select and display

    Hello!

    Here is what i am doing. I have this database and i need
    to grab some info out of it, multiply it, than select it
    and print it out. It is not printing out the info. Anyone
    got any ideas?

    Thanks!

    <%
    Response.Expire s = -1000 'Make sure the browser doesnt
    cache this page
    Response.Buffer = True 'enables our response.redire ct to
    work

    If Request.Form("v aluepassed") ="true" Then
    CheckLoginForm
    Else
    ShowLoginForm
    End If

    Sub CheckLoginForm
    Dim myconn, myconn2, myconn3, strsales, strorders
    **(didnt include the connection strings in here as they
    work)**

    myconn.execute( "UPDATE orders SET sales = (orders *
    29.99) , lastlogged = '" & Now() & "' WHERE company='"
    & "abc" & "';")

    strorders = myconn2.execute ("SELECT orders FROM orders
    WHERE company='" & "abc" & "';")
    strsales = myconn3.execute ("SELECT orders FROM orders
    WHERE company='" & "abc" & "';")

    End Sub
    %>

    <% Sub ShowLoginForm %>
    <table width="100%" border="0" cellspacing="0"
    cellpadding="0" >
    <tr>
    <td><div align="center"> <strong><font color="#0000FF"
    size="5" face="Verdana, Arial, Helvetica, sans-
    serif">Report</font></strong></div></td>
    </tr>
    <tr>
    <td><p>&nbsp; </p>
    <p><font size="2" face="Verdana, Arial, Helvetica, sans-
    serif">Welcome Back!</font></p>
    <form name="calculati ons" action="report. asp"
    method="post">
    <table width="100%" cellspacing="0" cellpadding="0" >
    <tr>
    <td width="24%" height="21"><st rong><font size="2"
    face="Verdana, Arial, Helvetica, sans-serif">Gross
    Orders</font></strong></td>
    <td width="76%"><st rong><font size="2" face="Verdana,
    Arial, Helvetica, sans-serif">Gross
    Sales</font></strong></td>
    </tr>
    tr>
    <td>

    <% Response.Write( strorders) %>

    </td>
    <td>

    <% Response.Write( strsales) %>
    </td>

    </tr>
    </table>
    </form><p>&nbsp;</p>
    <p>&nbsp;</p></td>
    </tr>
    </table>
    <% End Sub %>

  • Aaron Bertrand - MVP

    #2
    Re: Select and display

    Where do you define / open myconn, myconn2, myconn3? Why do you think you
    need three connection objects to query one database? Why are you doing this
    in a subroutine? What is the difference between strorders and strsales?
    Why do you think you can just response.write an object?


    "Help Please" <nospam@heh.com > wrote in message
    news:1f5301c373 03$0a74f8c0$a60 1280a@phx.gbl.. .[color=blue]
    > Hello!
    >
    > Here is what i am doing. I have this database and i need
    > to grab some info out of it, multiply it, than select it
    > and print it out. It is not printing out the info. Anyone
    > got any ideas?
    >
    > Thanks!
    >
    > <%
    > Response.Expire s = -1000 'Make sure the browser doesnt
    > cache this page
    > Response.Buffer = True 'enables our response.redire ct to
    > work
    >
    > If Request.Form("v aluepassed") ="true" Then
    > CheckLoginForm
    > Else
    > ShowLoginForm
    > End If
    >
    > Sub CheckLoginForm
    > Dim myconn, myconn2, myconn3, strsales, strorders
    > **(didnt include the connection strings in here as they
    > work)**
    >
    > myconn.execute( "UPDATE orders SET sales = (orders *
    > 29.99) , lastlogged = '" & Now() & "' WHERE company='"
    > & "abc" & "';")
    >
    > strorders = myconn2.execute ("SELECT orders FROM orders
    > WHERE company='" & "abc" & "';")
    > strsales = myconn3.execute ("SELECT orders FROM orders
    > WHERE company='" & "abc" & "';")
    >
    > End Sub
    > %>
    >
    > <% Sub ShowLoginForm %>
    > <table width="100%" border="0" cellspacing="0"
    > cellpadding="0" >
    > <tr>
    > <td><div align="center"> <strong><font color="#0000FF"
    > size="5" face="Verdana, Arial, Helvetica, sans-
    > serif">Report</font></strong></div></td>
    > </tr>
    > <tr>
    > <td><p>&nbsp; </p>
    > <p><font size="2" face="Verdana, Arial, Helvetica, sans-
    > serif">Welcome Back!</font></p>
    > <form name="calculati ons" action="report. asp"
    > method="post">
    > <table width="100%" cellspacing="0" cellpadding="0" >
    > <tr>
    > <td width="24%" height="21"><st rong><font size="2"
    > face="Verdana, Arial, Helvetica, sans-serif">Gross
    > Orders</font></strong></td>
    > <td width="76%"><st rong><font size="2" face="Verdana,
    > Arial, Helvetica, sans-serif">Gross
    > Sales</font></strong></td>
    > </tr>
    > tr>
    > <td>
    >
    > <% Response.Write( strorders) %>
    >
    > </td>
    > <td>
    >
    > <% Response.Write( strsales) %>
    > </td>
    >
    > </tr>
    > </table>
    > </form><p>&nbsp;</p>
    > <p>&nbsp;</p></td>
    > </tr>
    > </table>
    > <% End Sub %>
    >[/color]


    Comment

    • Jason Melville

      #3
      Re: Select and display

      For starters, myconn2.execute ("SELECT orders FROM orders
      WHERE company='" & "abc" & "';") and
      myconn3.execute ("SELECT orders FROM orders
      WHERE company='" & "abc" & "';")
      won't return strings. Set these values to recordsets.

      Secondly strsales and strorders are declared in a CheckLoginForm and are not
      available to ShowLoginForm.

      Finally, you don't need 3 connections, use one.
      Have a search through google or MSDN for recordsets etc in ASP.




      "Help Please" <nospam@heh.com > wrote in message
      news:1f5301c373 03$0a74f8c0$a60 1280a@phx.gbl.. .[color=blue]
      > Hello!
      >
      > Here is what i am doing. I have this database and i need
      > to grab some info out of it, multiply it, than select it
      > and print it out. It is not printing out the info. Anyone
      > got any ideas?
      >
      > Thanks!
      >
      > <%
      > Response.Expire s = -1000 'Make sure the browser doesnt
      > cache this page
      > Response.Buffer = True 'enables our response.redire ct to
      > work
      >
      > If Request.Form("v aluepassed") ="true" Then
      > CheckLoginForm
      > Else
      > ShowLoginForm
      > End If
      >
      > Sub CheckLoginForm
      > Dim myconn, myconn2, myconn3, strsales, strorders
      > **(didnt include the connection strings in here as they
      > work)**
      >
      > myconn.execute( "UPDATE orders SET sales = (orders *
      > 29.99) , lastlogged = '" & Now() & "' WHERE company='"
      > & "abc" & "';")
      >
      > strorders = myconn2.execute ("SELECT orders FROM orders
      > WHERE company='" & "abc" & "';")
      > strsales = myconn3.execute ("SELECT orders FROM orders
      > WHERE company='" & "abc" & "';")
      >
      > End Sub
      > %>
      >
      > <% Sub ShowLoginForm %>
      > <table width="100%" border="0" cellspacing="0"
      > cellpadding="0" >
      > <tr>
      > <td><div align="center"> <strong><font color="#0000FF"
      > size="5" face="Verdana, Arial, Helvetica, sans-
      > serif">Report</font></strong></div></td>
      > </tr>
      > <tr>
      > <td><p>&nbsp; </p>
      > <p><font size="2" face="Verdana, Arial, Helvetica, sans-
      > serif">Welcome Back!</font></p>
      > <form name="calculati ons" action="report. asp"
      > method="post">
      > <table width="100%" cellspacing="0" cellpadding="0" >
      > <tr>
      > <td width="24%" height="21"><st rong><font size="2"
      > face="Verdana, Arial, Helvetica, sans-serif">Gross
      > Orders</font></strong></td>
      > <td width="76%"><st rong><font size="2" face="Verdana,
      > Arial, Helvetica, sans-serif">Gross
      > Sales</font></strong></td>
      > </tr>
      > tr>
      > <td>
      >
      > <% Response.Write( strorders) %>
      >
      > </td>
      > <td>
      >
      > <% Response.Write( strsales) %>
      > </td>
      >
      > </tr>
      > </table>
      > </form><p>&nbsp;</p>
      > <p>&nbsp;</p></td>
      > </tr>
      > </table>
      > <% End Sub %>
      >[/color]


      Comment

      • me

        #4
        Re: Select and display

        I skipped defining the myconn connection strings becuase
        it was pointless ot put them in here since they work.
        strorders is the amount of orders taken
        strsales is the number of orders multiplyed by a price.

        Strsales and orders are variables not objects, unless i
        am wrong, so i thought i could display a variable.

        [color=blue]
        >-----Original Message-----
        >Where do you define / open myconn, myconn2, myconn3?[/color]
        Why do you think you[color=blue]
        >need three connection objects to query one database?[/color]
        Why are you doing this[color=blue]
        >in a subroutine? What is the difference between[/color]
        strorders and strsales?[color=blue]
        >Why do you think you can just response.write an object?
        >
        >
        >"Help Please" <nospam@heh.com > wrote in message
        >news:1f5301c37 303$0a74f8c0$a6 01280a@phx.gbl. ..[color=green]
        >> Hello!
        >>
        >> Here is what i am doing. I have this database and i[/color][/color]
        need[color=blue][color=green]
        >> to grab some info out of it, multiply it, than select[/color][/color]
        it[color=blue][color=green]
        >> and print it out. It is not printing out the info.[/color][/color]
        Anyone[color=blue][color=green]
        >> got any ideas?
        >>
        >> Thanks!
        >>
        >> <%
        >> Response.Expire s = -1000 'Make sure the browser doesnt
        >> cache this page
        >> Response.Buffer = True 'enables our response.redire ct[/color][/color]
        to[color=blue][color=green]
        >> work
        >>
        >> If Request.Form("v aluepassed") ="true" Then
        >> CheckLoginForm
        >> Else
        >> ShowLoginForm
        >> End If
        >>
        >> Sub CheckLoginForm
        >> Dim myconn, myconn2, myconn3, strsales, strorders
        >> **(didnt include the connection strings in here as they
        >> work)**
        >>
        >> myconn.execute( "UPDATE orders SET sales = (orders *
        >> 29.99) , lastlogged = '" & Now() & "' WHERE company='"
        >> & "abc" & "';")
        >>
        >> strorders = myconn2.execute ("SELECT orders FROM orders
        >> WHERE company='" & "abc" & "';")
        >> strsales = myconn3.execute ("SELECT orders FROM orders
        >> WHERE company='" & "abc" & "';")
        >>
        >> End Sub
        >> %>
        >>
        >> <% Sub ShowLoginForm %>
        >> <table width="100%" border="0" cellspacing="0"
        >> cellpadding="0" >
        >> <tr>
        >> <td><div align="center"> <strong><font color="#0000FF"
        >> size="5" face="Verdana, Arial, Helvetica, sans-
        >> serif">Report</font></strong></div></td>
        >> </tr>
        >> <tr>
        >> <td><p> </p>
        >> <p><font size="2" face="Verdana, Arial, Helvetica,[/color][/color]
        sans-[color=blue][color=green]
        >> serif">Welcome Back!</font></p>
        >> <form name="calculati ons" action="report. asp"
        >> method="post">
        >> <table width="100%" cellspacing="0" cellpadding="0" >
        >> <tr>
        >> <td width="24%" height="21"><st rong><font size="2"
        >> face="Verdana, Arial, Helvetica, sans-serif">Gross
        >> Orders</font></strong></td>
        >> <td width="76%"><st rong><font size="2" face="Verdana,
        >> Arial, Helvetica, sans-serif">Gross
        >> Sales</font></strong></td>
        >> </tr>
        >> tr>
        >> <td>
        >>
        >> <% Response.Write( strorders) %>
        >>
        >> </td>
        >> <td>
        >>
        >> <% Response.Write( strsales) %>
        >> </td>
        >>
        >> </tr>
        >> </table>
        >> </form><p> </p>
        >> <p> </p></td>
        >> </tr>
        >> </table>
        >> <% End Sub %>
        >>[/color]
        >
        >
        >.
        >[/color]

        Comment

        • Aaron Bertrand - MVP

          #5
          Re: Select and display

          > Strsales and orders are variables not objects, unless i[color=blue]
          > am wrong,[/color]

          No, they are recordset objects.


          Comment

          • Server

            #6
            Select and display

            Sorry i am using a SQL 2000 Server heh[color=blue]
            >-----Original Message-----
            >Function Orders
            >Dim myconn, myconn2, strorders
            >Set myconn = Server.CreateOb ject("ADODB.Con nection")
            >Set myconn2 = Server.CreateOb ject("ADODB.Con nection")
            >
            >myconn.execute ("UPDATE xxx set sales = (orders *[/color]
            29.99) ,[color=blue]
            >lastlogged = '" & Now() & "' WHERE company='" & "abc"
            >& "';")
            >
            >set strorders = myconn2.execute ("SELECT orders FROM xxx
            >WHERE company='" & "abc" & "';")
            >End Function
            >
            >
            >Function Sales
            >Dim myconn3, strsales
            >Set myconn3 = Server.CreateOb ject("ADODB.Con nection")
            >
            >
            >set strsales = myconn3.execute ("SELECT orders FROM xxx
            >WHERE company='" & "abc" & "';")
            >End Function
            >
            > <td><% Response.Write Orders() %
            ></td>
            > <td><% Response.Write Sales() %></td>
            >
            >Still aint working like this.
            >[color=green]
            >>-----Original Message-----
            >>Hello!
            >>
            >>Here is what i am doing. I have this database and i[/color][/color]
            need[color=blue][color=green]
            >>to grab some info out of it, multiply it, than select[/color][/color]
            it[color=blue][color=green]
            >>and print it out. It is not printing out the info.[/color]
            >Anyone[color=green]
            >>got any ideas?
            >>
            >>Thanks!
            >>
            >><%
            >>Response.Expi res = -1000 'Make sure the browser doesnt
            >>cache this page
            >>Response.Buff er = True 'enables our response.redire ct[/color][/color]
            to[color=blue][color=green]
            >>work
            >>
            >>If Request.Form("v aluepassed") ="true" Then
            >>CheckLoginFor m
            >>Else
            >>ShowLoginFo rm
            >>End If
            >>
            >>Sub CheckLoginForm
            >>Dim myconn, myconn2, myconn3, strsales, strorders
            >>**(didnt include the connection strings in here as they
            >>work)**
            >>
            >>myconn.execut e("UPDATE orders SET sales = (orders *
            >>29.99) , lastlogged = '" & Now() & "' WHERE company='"
            >>& "abc" & "';")
            >>
            >>strorders = myconn2.execute ("SELECT orders FROM orders
            >>WHERE company='" & "abc" & "';")
            >>strsales = myconn3.execute ("SELECT orders FROM orders
            >>WHERE company='" & "abc" & "';")
            >>
            >>End Sub
            >>%>
            >>
            >><% Sub ShowLoginForm %>
            >><table width="100%" border="0" cellspacing="0"
            >>cellpadding=" 0">
            >><tr>
            >><td><div align="center"> <strong><font color="#0000FF"
            >>size="5" face="Verdana, Arial, Helvetica, sans-
            >>serif">Report </font></strong></div></td>
            >></tr>
            >><tr>
            >><td><p> </p>
            >><p><font size="2" face="Verdana, Arial, Helvetica, sans-
            >>serif">Welcom e Back!</font></p>
            >><form name="calculati ons" action="report. asp"
            >>method="post" >
            >><table width="100%" cellspacing="0" cellpadding="0" >
            >><tr>
            >><td width="24%" height="21"><st rong><font size="2"
            >>face="Verdana , Arial, Helvetica, sans-serif">Gross
            >>Orders</font></strong></td>
            >><td width="76%"><st rong><font size="2" face="Verdana,
            >>Arial, Helvetica, sans-serif">Gross
            >>Sales</font></strong></td>
            >></tr>
            >>tr>
            >><td>
            >>
            >><% Response.Write( strorders) %>
            >>
            >></td>
            >><td>
            >>
            >><% Response.Write( strsales) %>
            >></td>
            >>
            >></tr>
            >></table>
            >></form><p> </p>
            >> <p> </p></td>
            >> </tr>
            >> </table>
            >><% End Sub %>
            >>
            >>.
            >>[/color]
            >.
            >[/color]

            Comment

            • Aaron Bertrand - MVP

              #7
              Re: Select and display

              Why do you change your name every time you post? Can you stop, so we don't
              get dizzy trying to figure out who is who?


              "Server" <type@nospam.co m> wrote in message
              news:151601c373 17$2585e5c0$a10 1280a@phx.gbl.. .[color=blue]
              > Sorry i am using a SQL 2000 Server heh[/color]


              Comment

              Working...