Aleks
asked on
Update current balance sql
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 .Connectio n")
conn.Open MM_eimmigration_STRING
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
end if
next
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.
---
<%
'-- create connection object and establish a connection to the database
set conn = Server.CreateObject("ADODB
conn.Open MM_eimmigration_STRING
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
end if
next
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks !
Open in new window
Caveat: this may allow SQL injection, when you don't check the content of your arrays. The both must only contain numbers.
A better approach would be using a parameterized query.