How should you complete the code?

DRAG DROP
You have an Azure SQL Database that contains two tables named Country and City.
You need to insert a country into the Country table and a city into the City table. The solution must meet the
following requirements:
If an error occurs while attempting to add the country, the city must NOT be added.
If an error occurs while attempting to add the city, the country must NOT be added.
How should you complete the code? To answer, drag the appropriate code blocks to the correct locations in the
answer area. Each code block may be used once, more than once, or not at all. You may need to drag the split
bar between panes or scroll to view content.
Select and Place:

DRAG DROP
You have an Azure SQL Database that contains two tables named Country and City.
You need to insert a country into the Country table and a city into the City table. The solution must meet the
following requirements:
If an error occurs while attempting to add the country, the city must NOT be added.
If an error occurs while attempting to add the city, the country must NOT be added.
How should you complete the code? To answer, drag the appropriate code blocks to the correct locations in the
answer area. Each code block may be used once, more than once, or not at all. You may need to drag the split
bar between panes or scroll to view content.
Select and Place:

Answer:

Explanation:
https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqltransaction(v=vs.110).aspx



Leave a Reply 5

Your email address will not be published. Required fields are marked *


Rick

Rick

save(“insert”)
rollback(“insert”)
commit()
rollback(“beginning”)

null

null

No, I think the original answer is correct. Rolling back to “inserted” state instead of “beginning” after the insert of city fails will result in the country being added to the database. Requirements state that should not be the case.

Rick

Rick

agree

Rick

Rick

seems it does not need save(“insert”) at all.

Jesley Cáceres Marcelino

Jesley Cáceres Marcelino

me too