Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate Sum In ASP Classic

Status
Not open for further replies.

anon1971

Programmer
Aug 9, 2008
88
US
Below is the code and I recieve no errors but it write mo data in the response.write?

set rs = Server.CreateObject ("ADODB.Recordset")
Set conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "Provider=SQLOLEDB;Server=SERVER\SQLEXPRESS;Database=GE_Data;Trusted_Connection=yes;"
Conn.Open

sql = "SELECT Sum(Cost)-Sum(Credit) AS SumCx FROM [LedgerD] Where [LedgerD].[ProjectID]=" & strProjectID & " And [LedgerD].[MethodID] = " & 1 & ""
rs.open sql, conn, 3, 3

Response.Write(SumCx)
 
SumCx is a value only in the recordset the ASP script doesn't 'know' it exists.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
In programming terminology
Code:
Response.Write(rs("SumCx"))
If you have Option explicit in your code, it would have spotted that SumCx was not declared.
 
Thanks guys works perfect with ether of xwb fixes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top