List:Internals« Previous MessageNext Message »
From:mhillyer Date:May 7 2005 10:58am
Subject:bk commit - mysqldoc@docsrva tree (Mike.Hillyer:1.2636)
View as plain text  
Below is the list of changes that have just been committed into a local
mysqldoc repository of root. When root does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.2636 05/05/07 02:58:30 Mike.Hillyer@stripped +1 -0
  More tweaks to the C/NET docs, just need reggie to add C# examples.

  Docs/connector-net.xml
    1.14 05/05/07 02:57:49 Mike.Hillyer@stripped +249 -91
    Added last classes, made some general edits.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	Mike.Hillyer
# Host:	www.openwin.org
# Root:	/home/mysqldoc/mysqldoc

--- 1.13/Docs/connector-net.xml	2005-05-07 01:37:41 -06:00
+++ 1.14/Docs/connector-net.xml	2005-05-07 02:57:49 -06:00
@@ -138,6 +138,13 @@
    <ulink
url="http://www.mysql.com/support/">http://www.mysql.com/support/</ulink>.
   </para>
 
+  <para>
+   This document is intended as a user's guide to &connector_net; and
+   not as a syntax reference. If you need detailed syntax information
+   you should read the <filename>Documentation.chm</filename> file
+   included with the &connector_net; distribution.
+  </para>
+
  </chapter>
 
 <!-- END INTRODUCTION -->
@@ -165,7 +172,7 @@
   </para>
 
   <para>
-   &connector_net;is available for download from
+   &connector_net; is available for download from
    <ulink
url="http://dev.mysql.com/downloads/connector/net/1.0.html">http://dev.mysql.com/downloads/connector/net/1.0.html</ulink>.
   </para>
 
@@ -258,10 +265,20 @@
     work with the provider.
    </para></listitem>
 
+   <listitem><para>
+    <literal>MySqlTransaction</literal>: Represents a SQL transaction to
+    be made in a MySQL database.
+   </para></listitem>
+
   </itemizedlist>
 
   <para>
    Each of these objects will be described in the upcoming sections.
+   These sections are intended to be an overview of the major classes of
+   &connector_net;, and not a syntax reference. If you need more
+   detailed information you should read the
+   <filename>Documentation.chm</filename> file included with the
+   &connector_net; distribution.
   </para>
 
   <sect1 id="connector-net-architecture-command">
@@ -278,8 +295,8 @@
     '@' symbol to mark parameters in SQL. This is incompatible with
     MySQL user variables, so the provider now uses the '?' symbol to
     locate parameters in SQL. To support older code, you can set 'old
-    syntax=yes' on your connection string. If you do this, please be
-    aware that an exception will not be throw if you fail to define a
+    syntax=yes' in your connection string. If you do this, please be
+    aware that an exception will not be thrown if you fail to define a
     parameter that you intended to use in your SQL.
    </para>
 
@@ -306,8 +323,9 @@
 
      <listitem><para>
       <literal>CommandType</literal>: Gets or sets a value indicating
-      how the CommandText property is to be interpreted. Only type
-      <literal>Text</literal> is currently supported.
+      how the CommandText property is to be interpreted. Possible types
+      are <literal>StoredProcedure</literal>,
+      <literal>TableDirect</literal>, and
<literal>Text</literal>.
      </para></listitem>
 
      <listitem><para>
@@ -316,11 +334,6 @@
      </para></listitem>
 
      <listitem><para>
-      <literal>Container</literal>: (inherited from Component) Gets the
-      IContainer that contains the Component.
-     </para></listitem>
-
-     <listitem><para>
       <literal>IsPrepared</literal>: Is true if this command has been
       prepared, false otherwise.
      </para></listitem>
@@ -330,11 +343,6 @@
      </para></listitem>
 
      <listitem><para>
-      <literal>Site</literal>: (inherited from Component) Gets or sets
-      the ISite of the Component.
-     </para></listitem>
-
-     <listitem><para>
       <literal>Transaction</literal>: Gets or sets the MySqlTransaction
       within which the MySqlCommand executes.
      </para></listitem>
@@ -374,13 +382,6 @@
      </para></listitem>
 
      <listitem><para>
-      <literal>CreateObjRef</literal>: (inherited from
-      MarshalByRefObject) Creates an object that contains all the
-      relevant information required to generate a proxy used to
-      communicate with a remote object.
-     </para></listitem>
-
-     <listitem><para>
       <literal>CreateParameter</literal>: Creates a new instance of a
       MySqlParameter object.
      </para></listitem>
@@ -391,18 +392,13 @@
      </para></listitem>
 
      <listitem><para>
-      <literal>Equals</literal>: (inherited from Object) Determines
-      whether the specified Object is equal to the current Object.
-     </para></listitem>
-
-     <listitem><para>
       <literal>ExecuteNonQuery</literal>: Executes a SQL statement
       against the connection and returns the number of rows affected.
      </para></listitem>
 
      <listitem><para>
-      <literal>ExecuteReader</literal>: Overloaded. Sends the
-      CommandText to the Connection and builds a MySqlDataReader.
+      <literal>ExecuteReader</literal>: Sends the CommandText to the
+      Connection and builds a MySqlDataReader.
      </para></listitem>
 
      <listitem><para>
@@ -412,36 +408,8 @@
      </para></listitem>
 
      <listitem><para>
-      <literal>GetHashCode</literal>: (inherited from Object) Serves as
-      a hash function for a particular type, suitable for use in hashing
-      algorithms and data structures like a hash table.
-     </para></listitem>
-
-     <listitem><para>
-      <literal>GetLifetimeService</literal>: (inherited from
-      MarshalByRefObject) Retrieves the current lifetime service object
-      that controls the lifetime policy for this instance.
-     </para></listitem>
-
-     <listitem><para>
-      <literal>GetType</literal>: (inherited from Object) Gets the Type
-      of the current instance.
-     </para></listitem>
-
-     <listitem><para>
-      <literal>InitializeLifetimeService</literal>: (inherited from
-      MarshalByRefObject) Obtains a lifetime service object to control
-      the lifetime policy for this instance.
-     </para></listitem>
-
-     <listitem><para>
       <literal>Prepare</literal>: Creates a prepared version of the
-      command on an instance of MySQL Server. <emphasis>This is
-      currently not supported.</emphasis>
-     </para></listitem>
-
-     <listitem><para>
-      <literal>ToString</literal>: (inherited from Component)
+      command on an instance of MySQL Server.
      </para></listitem>
 
     </itemizedlist>
@@ -720,24 +688,24 @@
 <programlisting>
     public static DataSet SelectRows(string myConnection, string mySelectQuery, string
myTableName)
     {
-    MySqlConnection myConn = new MySqlConnection(myConnection);
-    MySqlDataAdapter myDataAdapter = new MySqlDataAdapter();
-    myDataAdapter.SelectCommand = new MySqlCommand(mySelectQuery, myConn);
-    MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter);
+      MySqlConnection myConn = new MySqlConnection(myConnection);
+      MySqlDataAdapter myDataAdapter = new MySqlDataAdapter();
+      myDataAdapter.SelectCommand = new MySqlCommand(mySelectQuery, myConn);
+      MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter);
 
-    myConn.Open();
+      myConn.Open();
 
-    DataSet ds = new DataSet();
-    myDataAdapter.Fill(ds, myTableName);
+      DataSet ds = new DataSet();
+      myDataAdapter.Fill(ds, myTableName);
 
-    //code to modify data in DataSet here
+      //code to modify data in DataSet here
 
-    //Without the MySqlCommandBuilder this line would fail
-    myDataAdapter.Update(ds, myTableName);
+      //Without the MySqlCommandBuilder this line would fail
+      myDataAdapter.Update(ds, myTableName);
 
-    myConn.Close();
+      myConn.Close();
 
-    return ds;
+      return ds;
     }  
     </programlisting>
 
@@ -964,7 +932,7 @@
    <title>The MySqlDataAdapter Class</title>
 
    <para>
-    The MySQLDataAdapter, serves as a bridge between a DataSet and MySQL
+    The MySQLDataAdapter serves as a bridge between a DataSet and MySQL
     for retrieving and saving data. The MySQLDataAdapter provides this
     bridge by mapping Fill, which changes the data in the DataSet to
     match the data in the data source, and Update, which changes the
@@ -994,12 +962,6 @@
     facilitate the loading and updating of data.
    </para>
 
-   <para>
-    When an instance of MySQLDataAdapter is created, the read/write
-    properties are set to initial values. For a list of these values,
-    see the MySQLDataAdapter constructor.
-   </para>
-
    <sect2 id="connector-net-architecture-adapter-properties">
 
     <title>Properties</title>
@@ -1240,9 +1202,9 @@
      </para></listitem>
 
      <listitem><para>
-      <literal>Item</literal>: Overloaded. Overloaded. Gets the value of
-      a column in its native format. In C#, this property is the indexer
-      for the MySqlDataReader class.
+      <literal>Item</literal>: Gets the value of a column in its native
+      format. In C#, this property is the indexer for the
+      MySqlDataReader class.
      </para></listitem>
 
      <listitem><para>
@@ -1742,6 +1704,202 @@
 
 <!-- END HELPER CLASS -->
 
+  <sect1 id="connector-net-architecture-transaction">
+
+   <title>The MySqlTransaction Class</title>
+
+   <para>
+    Represents a SQL transaction to be made in a MySQL database.
+   </para>
+
+   <sect2 id="connector-net-architecture-transaction-properties">
+
+    <title>Properties</title>
+
+    <para>
+     The following properties are available:
+    </para>
+
+    <itemizedlist>
+
+     <listitem><para>
+      <literal>Connection</literal>: Gets the MySqlConnection object
+      associated with the transaction, or a null reference (Nothing in
+      Visual Basic) if the transaction is no longer valid.
+     </para></listitem>
+
+     <listitem><para>
+      <literal>IsolationLevel</literal>: Specifies the IsolationLevel
+      for this transaction.
+     </para></listitem>
+
+    </itemizedlist>
+
+   </sect2>
+
+<!-- END PROPERTIES -->
+
+   <sect2 id="connector-net-architecture-transaction-methods">
+
+    <title>Methods</title>
+
+    <para>
+     The following methods are available:
+    </para>
+
+    <itemizedlist>
+
+     <listitem><para>
+      <literal>Commit</literal>: Commits the database transaction.
+     </para></listitem>
+
+     <listitem><para>
+      <literal>Rollback</literal>: Rolls back a transaction from a
+      pending state.
+     </para></listitem>
+
+    </itemizedlist>
+
+   </sect2>
+
+<!-- END METHDOS -->
+
+   <sect2 id="connector-net-architecture-transaction-usage">
+
+    <title>Usage</title>
+
+    <para>
+     The following example creates a MySqlConnection and a
+     MySqlTransaction. It also demonstrates how to use the
+     BeginTransaction, Commit, and Rollback methods.
+    </para>
+
+    <sect3 id="connector-net-architecture-transaction-vb">
+
+     <title>VB.NET</title>
+
+     <para>
+      The following example shows how to use the MySqlTransaction class
+      with VB.NET:
+     </para>
+
+<programlisting>
+Public Sub RunTransaction(myConnString As String)
+    Dim myConnection As New MySqlConnection(myConnString)
+    myConnection.Open()
+    
+    Dim myCommand As MySqlCommand = myConnection.CreateCommand()
+    Dim myTrans As MySqlTransaction
+    
+    ' Start a local transaction
+    myTrans = myConnection.BeginTransaction()
+    ' Must assign both transaction object and connection
+    ' to Command object for a pending local transaction
+    myCommand.Connection = myConnection
+    myCommand.Transaction = myTrans
+    
+    Try
+      myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES
(100, 'Description')"
+      myCommand.ExecuteNonQuery()
+      myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES
(101, 'Description')"
+      myCommand.ExecuteNonQuery()
+      myTrans.Commit()
+      Console.WriteLine("Both records are written to database.")
+    Catch e As Exception
+      Try
+        myTrans.Rollback()
+      Catch ex As MySqlException
+        If Not myTrans.Connection Is Nothing Then
+          Console.WriteLine("An exception of type " &amp; ex.GetType().ToString()
&amp; _
+                            " was encountered while attempting to roll back the
transaction.")
+        End If
+      End Try
+    
+      Console.WriteLine("An exception of type " &amp; e.GetType().ToString()
&amp; _
+                      "was encountered while inserting the data.")
+      Console.WriteLine("Neither record was written to database.")
+    Finally
+      myConnection.Close()
+    End Try
+End Sub 'RunTransaction       
+      </programlisting>
+
+    </sect3>
+
+<!-- END VB -->
+
+    <sect3 id="connector-net-architecture-transaction-csharp">
+
+     <title>C#</title>
+
+     <para>
+      The following example shows how to use the MySqlTransaction class
+      with C#:
+     </para>
+
+<programlisting>
+public void RunTransaction(string myConnString) 
+ {
+    MySqlConnection myConnection = new MySqlConnection(myConnString);
+    myConnection.Open();
+
+    MySqlCommand myCommand = myConnection.CreateCommand();
+    MySqlTransaction myTrans;
+
+    // Start a local transaction
+    myTrans = myConnection.BeginTransaction();
+    // Must assign both transaction object and connection
+    // to Command object for a pending local transaction
+    myCommand.Connection = myConnection;
+    myCommand.Transaction = myTrans;
+
+    try
+    {
+      myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES
(100, 'Description')";
+      myCommand.ExecuteNonQuery();
+      myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES
(101, 'Description')";
+      myCommand.ExecuteNonQuery();
+      myTrans.Commit();
+      Console.WriteLine("Both records are written to database.");
+    }
+    catch(Exception e)
+    {
+      try
+      {
+        myTrans.Rollback();
+      }
+      catch (MySqlException ex)
+      {
+        if (myTrans.Connection != null)
+        {
+          Console.WriteLine("An exception of type " + ex.GetType() +
+                            " was encountered while attempting to roll back the
transaction.");
+        }
+      }
+    
+      Console.WriteLine("An exception of type " + e.GetType() +
+                        " was encountered while inserting the data.");
+      Console.WriteLine("Neither record was written to database.");
+    }
+    finally 
+    {
+      myConnection.Close();
+    }
+}       
+      </programlisting>
+
+    </sect3>
+
+<!-- END CSHARP -->
+
+   </sect2>
+
+<!-- END USAGE -->
+
+  </sect1>
+
+<!-- END TRANSACTION CLASS -->
+
  </chapter>
 
 <!-- END ARCHITECTURE -->
@@ -1915,7 +2073,7 @@
     </para>
 
 <programlisting>
-  FILL IN
+  C# EXAMPLE PENDING
   </programlisting>
 
     <para>
@@ -1949,7 +2107,7 @@
     </para>
 
 <programlisting>
-  FILL IN!
+  C# EXAMPLE PENDING
   </programlisting>
 
     <para>
@@ -2041,7 +2199,7 @@
     </para>
 
 <programlisting>
-  FILL IN 
+  C# EXAMPLE PENDING
   </programlisting>
 
    </section>
@@ -2153,7 +2311,7 @@
     </para>
 
 <programlisting>
-  FILL IN!
+  C# EXAMPLE PENDING
   </programlisting>
 
    </section>
@@ -2278,7 +2436,7 @@
     </para>
 
 <programlisting>
-FILL IN
+C# EXAMPLE PENDING
 </programlisting>
 
     <para>
@@ -2363,7 +2521,7 @@
     </para>
 
 <programlisting>
-FILL IN
+C# EXAMPLE PENDING
 </programlisting>
 
     <para>
@@ -2539,7 +2697,7 @@
     </para>
 
 <programlisting>
-  REGGIE ADD SOME SEMICOLONS TO THE PREVIOUS EXAMPLE AND PASTE IT HERE ;-)
+  C# EXAMPLE PENDING
  </programlisting>
 
     <para>
@@ -2631,7 +2789,7 @@
     </para>
 
 <programlisting>
-  ONCE AGAIN ADD SOME SEMICOLONS ;) 
+  C# EXAMPLE PENDING
  </programlisting>
 
     <para>
@@ -2750,7 +2908,7 @@
     </para>
 
 <programlisting>
- C# CODE GOES HERE
+ C# EXAMPLE PENDING
 </programlisting>
 
     <para>
@@ -2892,7 +3050,7 @@
     </para>
 
 <programlisting>
- YOU KNOW THE DRILL
+C# EXAMPLE PENDING
 </programlisting>
 
     <para>
@@ -3170,7 +3328,7 @@
     </para>
 
 <programlisting>
-  
+  C# EXAMPLE PENDING
   </programlisting>
 
     <para>
Thread
bk commit - mysqldoc@docsrva tree (Mike.Hillyer:1.2636)mhillyer7 May