Update current balance sql
Posted on 2014-10-21
I will check on this post tonight. Its the last portion of the code I have been working on, this is what I got so far:
'-- create connection object and establish a connection to the database
set conn = Server.CreateObject("ADODB.Connection")
id = request.form("id")
amounts = request.form("amount")
arrItemIDs = Split( itemIDs, "," )
arrAmounts = Split( amounts, "," )
'-- now loop through the array and insert into the database
for counter = 0 to UBound( arrItemIDs )
if arrItemIDs( counter ) <> "" then '-- you also may want to check to make sure it's an numerical value
sql = "Update BillPaymntsRecvd SET PmtRecd = ( )"
conn.Execute( sql ) '-- assumes you have a connection object created and connected to the database
if conn.State <> 0 then conn.Close
set conn = nothing
This goes through a comma separated array. What it should do is take the current value of the 'balance' and add the 'amount' to it, then go to the next record and so on.
In other words:
The table name is : BillingLines
The id= is the key we will use to go through the records
I need to do the following: Update BillingLines SET PmtRecd = PmtRecd + arrAmounts( counter )
So it will add the amount paid to the current payment received. I just need help with the SQL portion of the code.