console.writeline("update successful.")
catch e as exception
try
mytrans.rollback()
catch ex as sqlexception
if not mytrans.connection is nothing then
console.writeline("an exception of type " & ex.gettype().tostring() & _
" was encountered while attempting to roll back the transaction.")
end if
end try
console.writeline("an exception of type " & e.gettype().tostring() & " was encountered.")
console.writeline("update failed.")
end try
myconnection.close()
end sub
‘c#
public void runsqltransaction(sqldataadapter da, sqlconnection myconnection, dataset ds)
{
myconnection.open();
sqltransaction mytrans = myconnection.begintransaction();