From 0d74384e7d6d0cb62c292863995fd24528c54d14 Mon Sep 17 00:00:00 2001 From: Tsahi Asher Date: Mon, 8 May 2023 00:17:18 +0300 Subject: [PATCH] complete "Working with Distributed Transactions" section update links from docs.microsoft.com to learn.microsoft.com #2 --- daab/a00949.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/daab/a00949.html b/daab/a00949.html index d07c239..64671c5 100644 --- a/daab/a00949.html +++ b/daab/a00949.html @@ -216,7 +216,7 @@

// Create a Database object from the factory using the connection string name.
Database namedDB = factory.Create("ExampleDatabase");
-

where "ExampleDatabase" is a name of a connection string. With CreateDefault, the connection string specified by the defaultDatabase attribute of the dataConfiguration element in web.config is used, as described above. Using the default database is a useful approach because you can change which of the databases defined in your configuration is the default simply by editing the configuration file, without requiring recompilation or redeployment of the application.

+

where "ExampleDatabase" is a name of a connection string. With CreateDefault, the connection string specified by the defaultDatabase attribute of the dataConfiguration element in web.config is used, as described above. Using the default database is a useful approach because you can change which of the databases defined in your configuration is the default simply by editing the configuration file, without requiring recompilation or redeployment of the application.

Some features are only available in the concrete types for a specific database. For example, the ExecuteXmlReader method is only available in the SqlDatabase class. If you want to use such features, you must cast the database type you instantiate to the appropriate concrete type.

As alternative to using the DatabaseProviderFactory class, you could use the static DatabaseFactory façade to create your Database instances. You must invoke the SetDatabaseProviderFactory method to set the details of the default database from the configuration file.

DatabaseFactory.SetDatabaseProviderFactory(factory, false);
@@ -573,7 +573,9 @@

{
// perform data access here
}
-

+

The example uses the Microsoft Distributed Transaction Coordinator (DTC) service. You must ensure that this service is running before you execute the example; depending on your operating system it may not be set to start automatically. To start the service, open the Services MMC snap-in from your Administrative Tools menu, right-click on the Distributed Transaction Coordinator service, and click Start. To see the effects of the TransactionScope and the way that it promotes a transaction, open the Component Services MMC snap-in from your Administrative Tools menu and expand the Component Services node until you can see the Transaction List in the central pane of the snap-in.

+

Your code should call the Complete method of the TransactionScope object before it exits the using block in order to preserve the changes in the database, otherwise they are rolled back automatically.

+