Advanced Usage of SQLServer in ASP.NET
Source: Unknown Author: Unknown Recommended rating: Visits: 38
1. Simple data operations can write a single-band parameter SQL statement, then use mycm.parameters.add ("@ vName", you can also write into stored procedures, can pass into the parameter or return during the process Parameters, this programming is more objectized, and the return parameters can be obtained as follows ... VRT = mycm.parameters.add ("ReturnValues", SqldbType.int) VRT.Direction = mycm.parameters.ReturnValus ... cm.execute noneQuery () ReturnValue = Mycm.Parameters ("ReturnValues"). Value 'If it is the following syntax: vot = mycm.parameters.add ("@ outp", sqldbtype ...) vot.direction = mycm. Parameters.output ... cm.executennequery () OtValue = mycm.parameters ("@ outp"). Value ... ------- Correlect use of the following structure Create Procedur Namep (@ v1 nvarchar (88 ), @mon money @outp nvarchar (.) Output) AS ........ Return (Select Count (*) from ....) - Note: Stored Procedure Return Values can only be inteer types, Each SQLServer process is actually returned 0 2. Using the link buffer to add a buffer option in the SQLServer connection string: Connection Lifetime Connection ... 3. Transaction processing can be enabled in three ways: one : Database transaction refers to the database-ended code-enabled transaction, such as Create Produce Testtrans As Being Transaction Update Taba Set ... Update Tabb Set ... Commit Transaction .... Exception Rollback Transaction .... 2: ADO.NET transaction ... cma = new sqlcommand (", con) CMB = new sqlcommand ("", con) inc.open objtransaction =con.begintransaction cma.transaction = objtransaction cmb.Transaction = objtransaction try cma.exec .... cMb.exec ..... ObjTransaction.commit catch exec Exception ObjTransaction.rollback ... Finally Con.close () .... 3: ASP.NET page transaction