Select and display

H

Help Please

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.Expires = -1000 'Make sure the browser doesnt
cache this page
Response.Buffer = True 'enables our response.redirect to
work

If Request.Form("valuepassed") ="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="calculations" action="report.asp"
method="post">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="24%" height="21"><strong><font size="2"
face="Verdana, Arial, Helvetica, sans-serif">Gross
Orders</font></strong></td>
<td width="76%"><strong><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 %>
 
J

Jason Melville

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.
 
A

Aaron Bertrand - MVP

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?
 
M

me

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.
 
S

Server

Sorry i am using a SQL 2000 Server heh
-----Original Message-----
Function Orders
Dim myconn, myconn2, strorders
Set myconn = Server.CreateObject("ADODB.Connection")
Set myconn2 = Server.CreateObject("ADODB.Connection")

myconn.execute("UPDATE xxx set sales = (orders * 29.99) ,
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.CreateObject("ADODB.Connection")


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.

.
 
A

Aaron Bertrand - MVP

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,220
Latest member
AugustinaJ

Latest Threads

Top