Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-03-18 : 08:00:50
|
| Scott writes "Dear Team,I have a datagrid that a user can edit multiple rows on. The updated value are saved to the database using a single button on my form. I've wrapped up the update to the database in a transactions as I don't want only some of the values saved should a problem occur.My issue is this, in order to test my applications error handling I need to somehow cause the transaction to fail halfway through the updates so that everything get rolled back out and the application gets a error code. Can this be done?If it can be done, can it be done programmatically using a tool like NUnit for running automated tests?Any pointers would be greatly appreciated.Thanks for your help.Scott Fergusson." |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-03-18 : 09:10:08
|
| Of course it can be done. All you have to do is add a call to your transaction that will raise an error. Like "Select * from fakeTable". ie: when RaiseError check box is checked, add that statement. Or add/change data that would violate a database constraint. Hopefully, all your database activity is done via stored procedures. If so, you could easily add an optional parameter (@RaiseError) that when not null, raises an error. "if @RaiseError = 1 Raiserror('Test Error', 16, 1)"Be One with the OptimizerTG |
 |
|
|
|
|
|