addhandler custda.rowupdated, new sqlrowupdatedeventhandler(addressof onrowupdated)
dim custds as dataset = new dataset()
custda.fill(custds, "customers")
' modify the dataset contents.
custda.update(custds, "customers")
dim myrow as datarow
for each myrow in custds.tables("customers").rows
if myrow.haserrors then console.writeline(myrow(0) & vbcrlf & myrow.rowerror)
next
private shared sub onrowupdated(sender as object, args as sqlrowupdatedeventargs)
if args.recordsaffected = 0
args.row.rowerror = "optimistic concurrency violation encountered"
args.status = updatestatus.skipcurrentrow
end if
end sub
‘c#
sqlconnection nwindconn = new sqlconnection("data source=localhost;integrated security=sspi;initial catalog=northwind");
sqldataadapter custda = new sqldataadapter("select customerid, companyname from customers order by customerid", nwindconn);
// the update command checks for optimistic concurrency violations in the where clause.