Forum Moderators: open
Doesn't the Connection object provides more good performance than recordset? and more easier
to be implemented. For instance, I want to make a bank transaction, creadit one account and debit one accout as below:
account A transfer to account B
By Using connection object.
BeginTrans
con.execute("Update customer Set balance = balance - amount Where CusNo = 20")
con.execute("Update customer Set balance = balance + amount Where CusNo = 21")
CommitTrans / rollbackTrans if error
We can use transaction at this level, more stable and secure.
if we use recordset, we need to create two recordset:
sQL = "Select balance from customer where CusNo = 20"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open sQL, con
objRS("balance") = objRS("balance") - amount
objRS.Update
Response.Write ("Record Updated")
sQL2 = "Select balance from customer where CusNo = 21"
Set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open sQL, con
objRS2("balance") = objRS("balance") - amount
objRS2.Update
Response.Write ("Record Updated")
What will happen if the first transaction is not succeed? Can the recordset batchupdate be used to replace the transaction?