Hello, How can I add all fields in one column of a Microsoft SQL 2000 database? Below is my example. Thank you in advance.
Database:
-------
npoints
-------
3
------
4
------
6
------
8
------
Each one of the numbers in the db are the same variable in my UPDATE ASP code. Is there an easy way to have my script get the sum of these numbers so I can assign them to a new variable in my vbscript? My UPDATE function from my code is below as I have it now(not working).
If Request.Form("submit") = "Update" Then
While not rsStatus.eof
sID = rsStatus("ID")
smember= Replace(Trim(Request.Form("txtmember"& sID)),"'","''")
spoints= Replace(Trim(Request.Form("txtpoints"& sID)),"'","''")
snpoints= Replace(Trim(Request.Form("txtnpoints"& sID)),"'","''")
stpoints= Replace(Trim(Request.Form("txttpoints"& sID)),"'","''")
smopoints= Replace(Trim(Request.Form("txtmopoints"& sID)),"'","''")
syrpoints= Replace(Trim(Request.Form("txtyrpoints"& sID)),"'","''")
If sID = "1" then
syrpoints = snpoints + smopoints
smopoints = snpoints
stpoints = spoints-snpoints
spoints = stpoints
strSQL = "UPDATE Team SET yrpoints='"& syrpoints &"', mopoints='"& smopoints &"', points='"& spoints &"', npoints='"& snpoints &"', tpoints='"& stpoints &"' WHERE ID='1'"
db.Execute strSQL
else
syrpoints = snpoints + smopoints
smopoints = snpoints
strSQL = "UPDATE Team SET yrpoints='"& syrpoints &"', mopoints='"& smopoints &"', npoints='"& snpoints &"' WHERE ID="& sID
db.Execute strSQL
end if
strSQL = "UPDATE Team Set npoints='0', tpoints='0' WHERE ID="& sID
db.Execute strSQL
rsStatus.movenext
Wend
rsStatus.movefirst
End If
Database:
-------
npoints
-------
3
------
4
------
6
------
8
------
Each one of the numbers in the db are the same variable in my UPDATE ASP code. Is there an easy way to have my script get the sum of these numbers so I can assign them to a new variable in my vbscript? My UPDATE function from my code is below as I have it now(not working).
If Request.Form("submit") = "Update" Then
While not rsStatus.eof
sID = rsStatus("ID")
smember= Replace(Trim(Request.Form("txtmember"& sID)),"'","''")
spoints= Replace(Trim(Request.Form("txtpoints"& sID)),"'","''")
snpoints= Replace(Trim(Request.Form("txtnpoints"& sID)),"'","''")
stpoints= Replace(Trim(Request.Form("txttpoints"& sID)),"'","''")
smopoints= Replace(Trim(Request.Form("txtmopoints"& sID)),"'","''")
syrpoints= Replace(Trim(Request.Form("txtyrpoints"& sID)),"'","''")
If sID = "1" then
syrpoints = snpoints + smopoints
smopoints = snpoints
stpoints = spoints-snpoints
spoints = stpoints
strSQL = "UPDATE Team SET yrpoints='"& syrpoints &"', mopoints='"& smopoints &"', points='"& spoints &"', npoints='"& snpoints &"', tpoints='"& stpoints &"' WHERE ID='1'"
db.Execute strSQL
else
syrpoints = snpoints + smopoints
smopoints = snpoints
strSQL = "UPDATE Team SET yrpoints='"& syrpoints &"', mopoints='"& smopoints &"', npoints='"& snpoints &"' WHERE ID="& sID
db.Execute strSQL
end if
strSQL = "UPDATE Team Set npoints='0', tpoints='0' WHERE ID="& sID
db.Execute strSQL
rsStatus.movenext
Wend
rsStatus.movefirst
End If