1. A general error handling mode for SQL Server Stored Procedure transaction processing is roughly as follows: Create procdure prInsertProducts (@ intProductId int, @ chvProductName varchar (30), @ intProductCount int) ASDeclare @ intErrorCode intSelect @ intErrorCode = @ ErrorBegin transaction if @ intErrorCode = 0 begin-insert products (ProductID, ProductName, ProductCount) values (@ intProductId, @ chvProductName, @ intProductCount) select @ intErrorCode = @ Error -- check every execution of a t-SQL statement immediately, save the Error code to the local variable. end if @ intErrorCode = 0 begin-update products set ProductName = 'microcomputer' where ProductID = 5 Select @ intErrorCode = @ Error endif @ intErrorCode = 0 commit transactionelse rollback transaction Return @ intErrorCode -- it is best to Return the error code to the called stored procedure or application 2 ,. use transactions to process SqlConnection myConnection = new SqlConnection ("Data Source = localhost; Initial Catalog = Northwind; Integrated Security = SSPI;"); myConnection. open (); SqlTransaction myTrans = myConnection. beginTransaction (); // use New to generate a new transaction SqlCommand myCommand = New SqlCommand (); myCommand. transaction = myTrans; try {myCommand. commandText = "Update Address set location = '23 rain street 'where userid = '000000'"; myCommand. executeNonQuery (); myTrans. commit (); Console. writeLine ("Record is udated. ");} catch (Exception e) {myTrans. rollback (); Console. writeLine (e. toString (); Console. writeLine ("Sorry, Record can not be updated. ");} finally {myConnection. close ();}