<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FADO.Net%2FSqlTransaction</id>
		<title>Csharp/CSharp Tutorial/ADO.Net/SqlTransaction - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FADO.Net%2FSqlTransaction"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/ADO.Net/SqlTransaction&amp;action=history"/>
		<updated>2026-04-30T01:18:42Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/ADO.Net/SqlTransaction&amp;diff=6506&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/ADO.Net/SqlTransaction&amp;diff=6506&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/ADO.Net/SqlTransaction&amp;diff=6507&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/ADO.Net/SqlTransaction&amp;diff=6507&amp;oldid=prev"/>
				<updated>2010-05-26T12:19:16Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Explicit Transaction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Data.SqlClient;&lt;br /&gt;
using System.Transactions;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
    class Program&lt;br /&gt;
    {&lt;br /&gt;
        static void Main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            CommittableTransaction tx = new CommittableTransaction();&lt;br /&gt;
            SqlConnection conn = new SqlConnection(&amp;quot;data source=localhost; initial catalog=SampleDB; integrated security=SSPI;&amp;quot;);&lt;br /&gt;
            conn.Open();&lt;br /&gt;
            SqlCommand updateCommand = conn.CreateCommand();&lt;br /&gt;
            updateCommand.rumandText = &amp;quot;DELETE Employees WHERE ID &amp;gt; 3&amp;quot;;&lt;br /&gt;
            conn.EnlistTransaction(tx);&lt;br /&gt;
            updateCommand.ExecuteNonQuery();&lt;br /&gt;
            tx.Rollback();&lt;br /&gt;
            conn.Close();&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Implicit Transaction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Data.SqlClient;&lt;br /&gt;
using System.Transactions;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
    class Program&lt;br /&gt;
    {&lt;br /&gt;
        static void Main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            using (TransactionScope scope = new TransactionScope())&lt;br /&gt;
            {&lt;br /&gt;
                using (SqlConnection conn = new SqlConnection(&amp;quot;data source=localhost; initial catalog=SampleDB; Integrated Security=SSPI;&amp;quot;))&lt;br /&gt;
                {&lt;br /&gt;
                    conn.Open();&lt;br /&gt;
                    SqlCommand cmd = conn.CreateCommand();&lt;br /&gt;
                    cmd.rumandText = &amp;quot;DELETE Employees&amp;quot;;&lt;br /&gt;
                    cmd.ExecuteNonQuery();&lt;br /&gt;
                    int y = 1;&lt;br /&gt;
                    y -= 1;&lt;br /&gt;
                    Console.WriteLine(&amp;quot;{0}&amp;quot;, 1 / y);&lt;br /&gt;
                    &lt;br /&gt;
                }&lt;br /&gt;
                scope.ruplete();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Nested Implicit Transaction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Data.SqlClient;&lt;br /&gt;
using System.Transactions;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
    class Program&lt;br /&gt;
    {&lt;br /&gt;
        static SqlConnection conn;&lt;br /&gt;
        static void Main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            try&lt;br /&gt;
            {&lt;br /&gt;
                using (TransactionScope scope = new TransactionScope())&lt;br /&gt;
                {&lt;br /&gt;
                    using (conn = new SqlConnection(&amp;quot;data source=localhost; initial catalog=SampleDB; Integrated Security=SSPI;&amp;quot;))&lt;br /&gt;
                    {&lt;br /&gt;
                        conn.Open();&lt;br /&gt;
                        for (int x = 1; x &amp;lt; 8; x++)&lt;br /&gt;
                        {&lt;br /&gt;
                            using (TransactionScope scope1 = new TransactionScope())&lt;br /&gt;
                            {&lt;br /&gt;
                                SqlCommand cmd = conn.CreateCommand();&lt;br /&gt;
                                cmd.rumandText = &amp;quot;DELETE Employees WHERE ID = &amp;quot; + x.ToString();&lt;br /&gt;
                                cmd.ExecuteNonQuery();&lt;br /&gt;
                                if (x &amp;lt; 3)&lt;br /&gt;
                                    scope1.ruplete();&lt;br /&gt;
                            }&lt;br /&gt;
                        }&lt;br /&gt;
                    }&lt;br /&gt;
                    scope.ruplete();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            catch (TransactionAbortedException )&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(&amp;quot;One or more of the child scopes voted to abort the transaction.&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==the use of a transaction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Data.SqlClient;&lt;br /&gt;
class ExecuteTransaction {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        SqlConnection mySqlConnection = new SqlConnection(&amp;quot;server=localhost;database=Northwind;uid=sa;pwd=sa&amp;quot;);&lt;br /&gt;
        mySqlConnection.Open();&lt;br /&gt;
        SqlTransaction mySqlTransaction = mySqlConnection.BeginTransaction();&lt;br /&gt;
        SqlCommand mySqlCommand = mySqlConnection.CreateCommand();&lt;br /&gt;
        mySqlCommand.Transaction = mySqlTransaction;&lt;br /&gt;
        mySqlCommand.rumandText =&lt;br /&gt;
          &amp;quot;INSERT INTO Customers (&amp;quot; +&lt;br /&gt;
          &amp;quot;  CustomerID, CompanyName&amp;quot; +&lt;br /&gt;
          &amp;quot;) VALUES (&amp;quot; +&lt;br /&gt;
          &amp;quot;  &amp;quot;J3COM&amp;quot;, &amp;quot;Jason Price Corporation&amp;quot;&amp;quot; +&lt;br /&gt;
          &amp;quot;)&amp;quot;;&lt;br /&gt;
        mySqlCommand.ExecuteNonQuery();&lt;br /&gt;
        mySqlCommand.rumandText =&lt;br /&gt;
          &amp;quot;INSERT INTO Orders (&amp;quot; +&lt;br /&gt;
          &amp;quot;  CustomerID&amp;quot; +&lt;br /&gt;
          &amp;quot;) VALUES (&amp;quot; +&lt;br /&gt;
          &amp;quot;  &amp;quot;J3COM&amp;quot;&amp;quot; +&lt;br /&gt;
          &amp;quot;)&amp;quot;;&lt;br /&gt;
        mySqlCommand.ExecuteNonQuery();&lt;br /&gt;
        mySqlTransaction.rumit();&lt;br /&gt;
        mySqlConnection.Close();&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Updating Data Using Transactions==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Data.SqlClient;&lt;br /&gt;
&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    SqlConnection MyConnection = new SqlConnection(&amp;quot;server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI;&amp;quot;);&lt;br /&gt;
    MyConnection.Open();&lt;br /&gt;
    String MyString = &amp;quot;INSERT INTO Employee(ID, FirstName)VALUES(1, &amp;quot;Greg&amp;quot;)&amp;quot;;&lt;br /&gt;
    SqlTransaction MyTransaction = MyConnection.BeginTransaction();&lt;br /&gt;
    SqlCommand MyCmd = new SqlCommand(MyString, MyConnection, MyTransaction);&lt;br /&gt;
    MyCmd.ExecuteScalar();&lt;br /&gt;
    MyTransaction.rumit();&lt;br /&gt;
    MyConnection.Close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>