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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding MSSQL DB fields with vbscript

Status
Not open for further replies.

acewilli

IS-IT--Management
Apr 11, 2003
98
US
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
 
For get about this question. I found the answer. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top