Removed:
branches/1.0/mysqlclient/common/Resources.cs
Modified:
branches/1.0/mysqlclient/AssemblyInfo.cs
branches/1.0/mysqlclient/MySqlHelper.cs
branches/1.0/mysqlclient/MySqlPoolManager.cs
Log:
removed the old Resources.cs file
changed the files that has Unix line endings to have Windows line endings
Modified: branches/1.0/mysqlclient/AssemblyInfo.cs
===================================================================
--- branches/1.0/mysqlclient/AssemblyInfo.cs 2006-08-30 20:07:45 UTC (rev 330)
+++ branches/1.0/mysqlclient/AssemblyInfo.cs 2006-08-30 20:14:41 UTC (rev 331)
@@ -1,84 +1,84 @@
-// Copyright (C) 2004-2006 MySQL AB
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as published by
-// the Free Software Foundation
-//
-// There are special exceptions to the terms and conditions of the GPL
-// as it is applied to this software. View the full text of the
-// exception in file EXCEPTIONS in the directory of this software
-// distribution.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-using System;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Runtime.CompilerServices;
-
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("MySQL.Data.dll")]
-[assembly: AssemblyDescription("ADO.Net driver for MySQL")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("MySQL AB")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("Copyright 2004-2005, MySQL AB")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-[assembly: ComVisible(false)]
-[assembly: CLSCompliant(false)]
-
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("1.0.7.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-#if FINAL
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("ConnectorNet")]
-#endif
+// Copyright (C) 2004-2006 MySQL AB
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation
+//
+// There are special exceptions to the terms and conditions of the GPL
+// as it is applied to this software. View the full text of the
+// exception in file EXCEPTIONS in the directory of this software
+// distribution.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("MySQL.Data.dll")]
+[assembly: AssemblyDescription("ADO.Net driver for MySQL")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("MySQL AB")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("Copyright 2004-2005, MySQL AB")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: ComVisible(false)]
+[assembly: CLSCompliant(false)]
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: AssemblyVersion("1.0.7.*")]
+
+//
+// In order to sign your assembly you must specify a key to use. Refer to the
+// Microsoft .NET Framework documentation for more information on assembly signing.
+//
+// Use the attributes below to control which key is used for signing.
+//
+// Notes:
+// (*) If no key is specified, the assembly is not signed.
+// (*) KeyName refers to a key that has been installed in the Crypto Service
+// Provider (CSP) on your machine. KeyFile refers to a file which contains
+// a key.
+// (*) If the KeyFile and the KeyName values are both specified, the
+// following processing occurs:
+// (1) If the KeyName can be found in the CSP, that key is used.
+// (2) If the KeyName does not exist and the KeyFile does exist, the key
+// in the KeyFile is installed into the CSP and used.
+// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
+// When specifying the KeyFile, the location of the KeyFile should be
+// relative to the project output directory which is
+// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
+// located in the project directory, you would specify the AssemblyKeyFile
+// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
+// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
+// documentation for more information on this.
+//
+[assembly: AssemblyDelaySign(false)]
+#if FINAL
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("ConnectorNet")]
+#endif
Modified: branches/1.0/mysqlclient/MySqlHelper.cs
===================================================================
--- branches/1.0/mysqlclient/MySqlHelper.cs 2006-08-30 20:07:45 UTC (rev 330)
+++ branches/1.0/mysqlclient/MySqlHelper.cs 2006-08-30 20:14:41 UTC (rev 331)
@@ -1,364 +1,364 @@
-// Copyright (C) 2004-2006 MySQL AB
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as published by
-// the Free Software Foundation
-//
-// There are special exceptions to the terms and conditions of the GPL
-// as it is applied to this software. View the full text of the
-// exception in file EXCEPTIONS in the directory of this software
-// distribution.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-using System;
-using System.Data;
-using MySql.Data.MySqlClient;
-
-namespace MySql.Data.MySqlClient
-{
- /// <summary>
- /// Helper class that makes it easier to work with the provider.
- /// </summary>
- public sealed class MySqlHelper
- {
- // this class provides only static methods
- private MySqlHelper()
- {
- }
-
- #region ExecuteNonQuery
-
- /// <summary>
- /// Executes a single command against a MySQL database. The <see cref="MySqlConnection"/> is assumed to be
- /// open when the method is called and remains open after the method completes.
- /// </summary>
- /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
- /// <param name="commandText">SQL command to be executed</param>
- /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
- /// <returns></returns>
- public static int ExecuteNonQuery( MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters )
- {
- //create a command and prepare it for execution
- MySqlCommand cmd = new MySqlCommand();
- cmd.Connection = connection;
- cmd.CommandText = commandText;
- cmd.CommandType = CommandType.Text;
-
- if (commandParameters != null)
- foreach (MySqlParameter p in commandParameters)
- cmd.Parameters.Add( p );
-
- int result = cmd.ExecuteNonQuery();
- cmd.Parameters.Clear();
-
- return result;
- }
-
- /// <summary>
- /// Executes a single command against a MySQL database. A new <see cref="MySqlConnection"/> is created
- /// using the <see cref="MySqlConnection.ConnectionString"/> given.
- /// </summary>
- /// <param name="connectionString"><see cref="MySqlConnection.ConnectionString"/> to use</param>
- /// <param name="commandText">SQL command to be executed</param>
- /// <param name="parms">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
- /// <returns></returns>
- public static int ExecuteNonQuery( string connectionString, string commandText, params MySqlParameter[] parms )
- {
- //create & open a SqlConnection, and dispose of it after we are done.
- using (MySqlConnection cn = new MySqlConnection(connectionString))
- {
- cn.Open();
-
- //call the overload that takes a connection in place of the connection string
- return ExecuteNonQuery(cn, commandText, parms );
- }
- }
- #endregion
-
- #region ExecuteDataSet
-
- /// <summary>
- /// Executes a single SQL command and returns the first row of the resultset. A new MySqlConnection object
- /// is created, opened, and closed during this method.
- /// </summary>
- /// <param name="connectionString">Settings to be used for the connection</param>
- /// <param name="commandText">Command to execute</param>
- /// <param name="parms">Parameters to use for the command</param>
- /// <returns>DataRow containing the first row of the resultset</returns>
- public static DataRow ExecuteDataRow( string connectionString, string commandText, params MySqlParameter[] parms )
- {
- DataSet ds = ExecuteDataset( connectionString, commandText, parms );
- if (ds == null) return null;
- if (ds.Tables.Count == 0) return null;
- if (ds.Tables[0].Rows.Count == 0) return null;
- return ds.Tables[0].Rows[0];
- }
-
- /// <summary>
- /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
- /// A new MySqlConnection object is created, opened, and closed during this method.
- /// </summary>
- /// <param name="connectionString">Settings to be used for the connection</param>
- /// <param name="commandText">Command to execute</param>
- /// <returns><see cref="DataSet"/> containing the resultset</returns>
- public static DataSet ExecuteDataset(string connectionString, string commandText)
- {
- //pass through the call providing null for the set of SqlParameters
- return ExecuteDataset(connectionString, commandText, (MySqlParameter[])null);
- }
-
- /// <summary>
- /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
- /// A new MySqlConnection object is created, opened, and closed during this method.
- /// </summary>
- /// <param name="connectionString">Settings to be used for the connection</param>
- /// <param name="commandText">Command to execute</param>
- /// <param name="commandParameters">Parameters to use for the command</param>
- /// <returns><see cref="DataSet"/> containing the resultset</returns>
- public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters)
- {
- //create & open a SqlConnection, and dispose of it after we are done.
- using (MySqlConnection cn = new MySqlConnection(connectionString))
- {
- cn.Open();
-
- //call the overload that takes a connection in place of the connection string
- return ExecuteDataset(cn, commandText, commandParameters);
- }
- }
-
- /// <summary>
- /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
- /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
- /// of this method.
- /// </summary>
- /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
- /// <param name="commandText">Command to execute</param>
- /// <returns><see cref="DataSet"/> containing the resultset</returns>
- public static DataSet ExecuteDataset(MySqlConnection connection, string commandText)
- {
- //pass through the call providing null for the set of SqlParameters
- return ExecuteDataset(connection, commandText, (MySqlParameter[])null);
- }
-
- /// <summary>
- /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
- /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
- /// of this method.
- /// </summary>
- /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
- /// <param name="commandText">Command to execute</param>
- /// <param name="commandParameters">Parameters to use for the command</param>
- /// <returns><see cref="DataSet"/> containing the resultset</returns>
- public static DataSet ExecuteDataset(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
- {
- //create a command and prepare it for execution
- MySqlCommand cmd = new MySqlCommand();
- cmd.Connection = connection;
- cmd.CommandText = commandText;
- cmd.CommandType = CommandType.Text;
-
- if (commandParameters != null)
- foreach (MySqlParameter p in commandParameters)
- cmd.Parameters.Add( p );
-
- //create the DataAdapter & DataSet
- MySqlDataAdapter da = new MySqlDataAdapter(cmd);
- DataSet ds = new DataSet();
-
- //fill the DataSet using default values for DataTable names, etc.
- da.Fill(ds);
-
- // detach the MySqlParameters from the command object, so they can be used again.
- cmd.Parameters.Clear();
-
- //return the dataset
- return ds;
- }
-
- /// <summary>
- /// Updates the given table with data from the given <see cref="DataSet"/>
- /// </summary>
- /// <param name="connectionString">Settings to use for the update</param>
- /// <param name="commandText">Command text to use for the update</param>
- /// <param name="ds"><see cref="DataSet"/> containing the new data to use in the update</param>
- /// <param name="tablename">Tablename in the dataset to update</param>
- public static void UpdateDataSet( string connectionString, string commandText, DataSet ds, string tablename )
- {
- MySqlConnection cn = new MySqlConnection( connectionString );
- cn.Open();
- MySqlDataAdapter da = new MySqlDataAdapter( commandText, cn );
- MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
- cb.ToString();
- da.Update( ds, tablename );
- cn.Close();
- }
-
- #endregion
-
- #region ExecuteDataReader
-
- /// <summary>
- /// Executes a single command against a MySQL database, possibly inside an existing transaction.
- /// </summary>
- /// <param name="connection"><see cref="MySqlConnection"/> object to use for the command</param>
- /// <param name="transaction"><see cref="MySqlTransaction"/> object to use for the command</param>
- /// <param name="commandText">Command text to use</param>
- /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
- /// <param name="ExternalConn">True if the connection should be preserved, false if not</param>
- /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
- private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn )
- {
- //create a command and prepare it for execution
- MySqlCommand cmd = new MySqlCommand();
- cmd.Connection = connection;
- cmd.Transaction = transaction;
- cmd.CommandText = commandText;
- cmd.CommandType = CommandType.Text;
-
- if (commandParameters != null)
- foreach (MySqlParameter p in commandParameters)
- cmd.Parameters.Add( p );
-
- //create a reader
- MySqlDataReader dr;
-
- // call ExecuteReader with the appropriate CommandBehavior
- if (ExternalConn)
- {
- dr = cmd.ExecuteReader();
- }
- else
- {
- dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
- }
-
- // detach the SqlParameters from the command object, so they can be used again.
- cmd.Parameters.Clear();
-
- return dr;
- }
-
- /// <summary>
- /// Executes a single command against a MySQL database.
- /// </summary>
- /// <param name="connectionString">Settings to use for this command</param>
- /// <param name="commandText">Command text to use</param>
- /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
- public static MySqlDataReader ExecuteReader(string connectionString, string commandText)
- {
- //pass through the call providing null for the set of SqlParameters
- return ExecuteReader(connectionString, commandText, (MySqlParameter[])null);
- }
-
- /// <summary>
- /// Executes a single command against a MySQL database.
- /// </summary>
- /// <param name="connectionString">Settings to use for this command</param>
- /// <param name="commandText">Command text to use</param>
- /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
- /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
- public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters)
- {
- //create & open a SqlConnection
- MySqlConnection cn = new MySqlConnection(connectionString);
- cn.Open();
-
- try
- {
- //call the private overload that takes an internally owned connection in place of the connection string
- return ExecuteReader(cn, null, commandText, commandParameters, false );
- }
- catch
- {
- //if we fail to return the SqlDatReader, we need to close the connection ourselves
- cn.Close();
- throw;
- }
- }
- #endregion
-
- #region ExecuteScalar
-
- /// <summary>
- /// Execute a single command against a MySQL database.
- /// </summary>
- /// <param name="connectionString">Settings to use for the update</param>
- /// <param name="commandText">Command text to use for the update</param>
- /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
- public static object ExecuteScalar(string connectionString, string commandText)
- {
- //pass through the call providing null for the set of MySqlParameters
- return ExecuteScalar(connectionString, commandText, (MySqlParameter[])null);
- }
-
- /// <summary>
- /// Execute a single command against a MySQL database.
- /// </summary>
- /// <param name="connectionString">Settings to use for the command</param>
- /// <param name="commandText">Command text to use for the command</param>
- /// <param name="commandParameters">Parameters to use for the command</param>
- /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
- public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters)
- {
- //create & open a SqlConnection, and dispose of it after we are done.
- using (MySqlConnection cn = new MySqlConnection(connectionString))
- {
- cn.Open();
-
- //call the overload that takes a connection in place of the connection string
- return ExecuteScalar(cn, commandText, commandParameters);
- }
- }
-
- /// <summary>
- /// Execute a single command against a MySQL database.
- /// </summary>
- /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
- /// <param name="commandText">Command text to use for the command</param>
- /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
- public static object ExecuteScalar(MySqlConnection connection, string commandText)
- {
- //pass through the call providing null for the set of MySqlParameters
- return ExecuteScalar(connection, commandText, (MySqlParameter[])null);
- }
-
- /// <summary>
- /// Execute a single command against a MySQL database.
- /// </summary>
- /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
- /// <param name="commandText">Command text to use for the command</param>
- /// <param name="commandParameters">Parameters to use for the command</param>
- /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
- public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
- {
- //create a command and prepare it for execution
- MySqlCommand cmd = new MySqlCommand();
- cmd.Connection = connection;
- cmd.CommandText = commandText;
- cmd.CommandType = CommandType.Text;
-
- if (commandParameters != null)
- foreach (MySqlParameter p in commandParameters)
- cmd.Parameters.Add( p );
-
- //execute the command & return the results
- object retval = cmd.ExecuteScalar();
-
- // detach the SqlParameters from the command object, so they can be used again.
- cmd.Parameters.Clear();
- return retval;
-
- }
-
- #endregion
- }
-}
+// Copyright (C) 2004-2006 MySQL AB
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation
+//
+// There are special exceptions to the terms and conditions of the GPL
+// as it is applied to this software. View the full text of the
+// exception in file EXCEPTIONS in the directory of this software
+// distribution.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+using System;
+using System.Data;
+using MySql.Data.MySqlClient;
+
+namespace MySql.Data.MySqlClient
+{
+ /// <summary>
+ /// Helper class that makes it easier to work with the provider.
+ /// </summary>
+ public sealed class MySqlHelper
+ {
+ // this class provides only static methods
+ private MySqlHelper()
+ {
+ }
+
+ #region ExecuteNonQuery
+
+ /// <summary>
+ /// Executes a single command against a MySQL database. The <see cref="MySqlConnection"/> is assumed to be
+ /// open when the method is called and remains open after the method completes.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
+ /// <param name="commandText">SQL command to be executed</param>
+ /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
+ /// <returns></returns>
+ public static int ExecuteNonQuery( MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters )
+ {
+ //create a command and prepare it for execution
+ MySqlCommand cmd = new MySqlCommand();
+ cmd.Connection = connection;
+ cmd.CommandText = commandText;
+ cmd.CommandType = CommandType.Text;
+
+ if (commandParameters != null)
+ foreach (MySqlParameter p in commandParameters)
+ cmd.Parameters.Add( p );
+
+ int result = cmd.ExecuteNonQuery();
+ cmd.Parameters.Clear();
+
+ return result;
+ }
+
+ /// <summary>
+ /// Executes a single command against a MySQL database. A new <see cref="MySqlConnection"/> is created
+ /// using the <see cref="MySqlConnection.ConnectionString"/> given.
+ /// </summary>
+ /// <param name="connectionString"><see cref="MySqlConnection.ConnectionString"/> to use</param>
+ /// <param name="commandText">SQL command to be executed</param>
+ /// <param name="parms">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
+ /// <returns></returns>
+ public static int ExecuteNonQuery( string connectionString, string commandText, params MySqlParameter[] parms )
+ {
+ //create & open a SqlConnection, and dispose of it after we are done.
+ using (MySqlConnection cn = new MySqlConnection(connectionString))
+ {
+ cn.Open();
+
+ //call the overload that takes a connection in place of the connection string
+ return ExecuteNonQuery(cn, commandText, parms );
+ }
+ }
+ #endregion
+
+ #region ExecuteDataSet
+
+ /// <summary>
+ /// Executes a single SQL command and returns the first row of the resultset. A new MySqlConnection object
+ /// is created, opened, and closed during this method.
+ /// </summary>
+ /// <param name="connectionString">Settings to be used for the connection</param>
+ /// <param name="commandText">Command to execute</param>
+ /// <param name="parms">Parameters to use for the command</param>
+ /// <returns>DataRow containing the first row of the resultset</returns>
+ public static DataRow ExecuteDataRow( string connectionString, string commandText, params MySqlParameter[] parms )
+ {
+ DataSet ds = ExecuteDataset( connectionString, commandText, parms );
+ if (ds == null) return null;
+ if (ds.Tables.Count == 0) return null;
+ if (ds.Tables[0].Rows.Count == 0) return null;
+ return ds.Tables[0].Rows[0];
+ }
+
+ /// <summary>
+ /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
+ /// A new MySqlConnection object is created, opened, and closed during this method.
+ /// </summary>
+ /// <param name="connectionString">Settings to be used for the connection</param>
+ /// <param name="commandText">Command to execute</param>
+ /// <returns><see cref="DataSet"/> containing the resultset</returns>
+ public static DataSet ExecuteDataset(string connectionString, string commandText)
+ {
+ //pass through the call providing null for the set of SqlParameters
+ return ExecuteDataset(connectionString, commandText, (MySqlParameter[])null);
+ }
+
+ /// <summary>
+ /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
+ /// A new MySqlConnection object is created, opened, and closed during this method.
+ /// </summary>
+ /// <param name="connectionString">Settings to be used for the connection</param>
+ /// <param name="commandText">Command to execute</param>
+ /// <param name="commandParameters">Parameters to use for the command</param>
+ /// <returns><see cref="DataSet"/> containing the resultset</returns>
+ public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters)
+ {
+ //create & open a SqlConnection, and dispose of it after we are done.
+ using (MySqlConnection cn = new MySqlConnection(connectionString))
+ {
+ cn.Open();
+
+ //call the overload that takes a connection in place of the connection string
+ return ExecuteDataset(cn, commandText, commandParameters);
+ }
+ }
+
+ /// <summary>
+ /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
+ /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
+ /// of this method.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
+ /// <param name="commandText">Command to execute</param>
+ /// <returns><see cref="DataSet"/> containing the resultset</returns>
+ public static DataSet ExecuteDataset(MySqlConnection connection, string commandText)
+ {
+ //pass through the call providing null for the set of SqlParameters
+ return ExecuteDataset(connection, commandText, (MySqlParameter[])null);
+ }
+
+ /// <summary>
+ /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
+ /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
+ /// of this method.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
+ /// <param name="commandText">Command to execute</param>
+ /// <param name="commandParameters">Parameters to use for the command</param>
+ /// <returns><see cref="DataSet"/> containing the resultset</returns>
+ public static DataSet ExecuteDataset(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
+ {
+ //create a command and prepare it for execution
+ MySqlCommand cmd = new MySqlCommand();
+ cmd.Connection = connection;
+ cmd.CommandText = commandText;
+ cmd.CommandType = CommandType.Text;
+
+ if (commandParameters != null)
+ foreach (MySqlParameter p in commandParameters)
+ cmd.Parameters.Add( p );
+
+ //create the DataAdapter & DataSet
+ MySqlDataAdapter da = new MySqlDataAdapter(cmd);
+ DataSet ds = new DataSet();
+
+ //fill the DataSet using default values for DataTable names, etc.
+ da.Fill(ds);
+
+ // detach the MySqlParameters from the command object, so they can be used again.
+ cmd.Parameters.Clear();
+
+ //return the dataset
+ return ds;
+ }
+
+ /// <summary>
+ /// Updates the given table with data from the given <see cref="DataSet"/>
+ /// </summary>
+ /// <param name="connectionString">Settings to use for the update</param>
+ /// <param name="commandText">Command text to use for the update</param>
+ /// <param name="ds"><see cref="DataSet"/> containing the new data to use in the update</param>
+ /// <param name="tablename">Tablename in the dataset to update</param>
+ public static void UpdateDataSet( string connectionString, string commandText, DataSet ds, string tablename )
+ {
+ MySqlConnection cn = new MySqlConnection( connectionString );
+ cn.Open();
+ MySqlDataAdapter da = new MySqlDataAdapter( commandText, cn );
+ MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
+ cb.ToString();
+ da.Update( ds, tablename );
+ cn.Close();
+ }
+
+ #endregion
+
+ #region ExecuteDataReader
+
+ /// <summary>
+ /// Executes a single command against a MySQL database, possibly inside an existing transaction.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use for the command</param>
+ /// <param name="transaction"><see cref="MySqlTransaction"/> object to use for the command</param>
+ /// <param name="commandText">Command text to use</param>
+ /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
+ /// <param name="ExternalConn">True if the connection should be preserved, false if not</param>
+ /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
+ private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn )
+ {
+ //create a command and prepare it for execution
+ MySqlCommand cmd = new MySqlCommand();
+ cmd.Connection = connection;
+ cmd.Transaction = transaction;
+ cmd.CommandText = commandText;
+ cmd.CommandType = CommandType.Text;
+
+ if (commandParameters != null)
+ foreach (MySqlParameter p in commandParameters)
+ cmd.Parameters.Add( p );
+
+ //create a reader
+ MySqlDataReader dr;
+
+ // call ExecuteReader with the appropriate CommandBehavior
+ if (ExternalConn)
+ {
+ dr = cmd.ExecuteReader();
+ }
+ else
+ {
+ dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
+ }
+
+ // detach the SqlParameters from the command object, so they can be used again.
+ cmd.Parameters.Clear();
+
+ return dr;
+ }
+
+ /// <summary>
+ /// Executes a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connectionString">Settings to use for this command</param>
+ /// <param name="commandText">Command text to use</param>
+ /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
+ public static MySqlDataReader ExecuteReader(string connectionString, string commandText)
+ {
+ //pass through the call providing null for the set of SqlParameters
+ return ExecuteReader(connectionString, commandText, (MySqlParameter[])null);
+ }
+
+ /// <summary>
+ /// Executes a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connectionString">Settings to use for this command</param>
+ /// <param name="commandText">Command text to use</param>
+ /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
+ /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
+ public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters)
+ {
+ //create & open a SqlConnection
+ MySqlConnection cn = new MySqlConnection(connectionString);
+ cn.Open();
+
+ try
+ {
+ //call the private overload that takes an internally owned connection in place of the connection string
+ return ExecuteReader(cn, null, commandText, commandParameters, false );
+ }
+ catch
+ {
+ //if we fail to return the SqlDatReader, we need to close the connection ourselves
+ cn.Close();
+ throw;
+ }
+ }
+ #endregion
+
+ #region ExecuteScalar
+
+ /// <summary>
+ /// Execute a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connectionString">Settings to use for the update</param>
+ /// <param name="commandText">Command text to use for the update</param>
+ /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
+ public static object ExecuteScalar(string connectionString, string commandText)
+ {
+ //pass through the call providing null for the set of MySqlParameters
+ return ExecuteScalar(connectionString, commandText, (MySqlParameter[])null);
+ }
+
+ /// <summary>
+ /// Execute a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connectionString">Settings to use for the command</param>
+ /// <param name="commandText">Command text to use for the command</param>
+ /// <param name="commandParameters">Parameters to use for the command</param>
+ /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
+ public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters)
+ {
+ //create & open a SqlConnection, and dispose of it after we are done.
+ using (MySqlConnection cn = new MySqlConnection(connectionString))
+ {
+ cn.Open();
+
+ //call the overload that takes a connection in place of the connection string
+ return ExecuteScalar(cn, commandText, commandParameters);
+ }
+ }
+
+ /// <summary>
+ /// Execute a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
+ /// <param name="commandText">Command text to use for the command</param>
+ /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
+ public static object ExecuteScalar(MySqlConnection connection, string commandText)
+ {
+ //pass through the call providing null for the set of MySqlParameters
+ return ExecuteScalar(connection, commandText, (MySqlParameter[])null);
+ }
+
+ /// <summary>
+ /// Execute a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
+ /// <param name="commandText">Command text to use for the command</param>
+ /// <param name="commandParameters">Parameters to use for the command</param>
+ /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
+ public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
+ {
+ //create a command and prepare it for execution
+ MySqlCommand cmd = new MySqlCommand();
+ cmd.Connection = connection;
+ cmd.CommandText = commandText;
+ cmd.CommandType = CommandType.Text;
+
+ if (commandParameters != null)
+ foreach (MySqlParameter p in commandParameters)
+ cmd.Parameters.Add( p );
+
+ //execute the command & return the results
+ object retval = cmd.ExecuteScalar();
+
+ // detach the SqlParameters from the command object, so they can be used again.
+ cmd.Parameters.Clear();
+ return retval;
+
+ }
+
+ #endregion
+ }
+}
Modified: branches/1.0/mysqlclient/MySqlPoolManager.cs
===================================================================
--- branches/1.0/mysqlclient/MySqlPoolManager.cs 2006-08-30 20:07:45 UTC (rev 330)
+++ branches/1.0/mysqlclient/MySqlPoolManager.cs 2006-08-30 20:14:41 UTC (rev 331)
@@ -1,84 +1,84 @@
-// Copyright (C) 2004-2006 MySQL AB
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as published by
-// the Free Software Foundation
-//
-// There are special exceptions to the terms and conditions of the GPL
-// as it is applied to this software. View the full text of the
-// exception in file EXCEPTIONS in the directory of this software
-// distribution.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-using System;
-using MySql.Data.Common;
-using System.Collections;
-
-namespace MySql.Data.MySqlClient
-{
- /// <summary>
- /// Summary description for MySqlPoolManager.
- /// </summary>
- internal sealed class MySqlPoolManager
- {
- private static Hashtable pools;
-
- public MySqlPoolManager()
- {
- }
-
- /// <summary>
- ///
- /// </summary>
- private static void Initialize()
- {
- pools = new Hashtable();
- }
-
- public static MySqlPool GetPool(MySqlConnectionString settings)
- {
- // make sure the manager is initialized
- if (MySqlPoolManager.pools == null)
- MySqlPoolManager.Initialize();
-
- string text = settings.GetConnectionString(true);
-
- lock( pools.SyncRoot )
- {
- MySqlPool pool;
- if (!pools.Contains( text ))
- {
- pool = new MySqlPool( settings );
- pools.Add( text, pool );
- }
- else
- {
- pool = (pools[text] as MySqlPool);
- pool.Settings = settings;
- }
-
- return pool;
- }
- }
-
- public static void ReleaseConnection( Driver driver )
- {
- lock (pools.SyncRoot)
- {
- string key = driver.Settings.GetConnectionString(true);
- MySqlPool pool = (MySqlPool)pools[ key ];
- if (pool == null)
- throw new MySqlException("Pooling exception: Unable to find original pool for connection");
- pool.ReleaseConnection( driver );
- }
- }
- }
-}
+// Copyright (C) 2004-2006 MySQL AB
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation
+//
+// There are special exceptions to the terms and conditions of the GPL
+// as it is applied to this software. View the full text of the
+// exception in file EXCEPTIONS in the directory of this software
+// distribution.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+using System;
+using MySql.Data.Common;
+using System.Collections;
+
+namespace MySql.Data.MySqlClient
+{
+ /// <summary>
+ /// Summary description for MySqlPoolManager.
+ /// </summary>
+ internal sealed class MySqlPoolManager
+ {
+ private static Hashtable pools;
+
+ public MySqlPoolManager()
+ {
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private static void Initialize()
+ {
+ pools = new Hashtable();
+ }
+
+ public static MySqlPool GetPool(MySqlConnectionString settings)
+ {
+ // make sure the manager is initialized
+ if (MySqlPoolManager.pools == null)
+ MySqlPoolManager.Initialize();
+
+ string text = settings.GetConnectionString(true);
+
+ lock( pools.SyncRoot )
+ {
+ MySqlPool pool;
+ if (!pools.Contains( text ))
+ {
+ pool = new MySqlPool( settings );
+ pools.Add( text, pool );
+ }
+ else
+ {
+ pool = (pools[text] as MySqlPool);
+ pool.Settings = settings;
+ }
+
+ return pool;
+ }
+ }
+
+ public static void ReleaseConnection( Driver driver )
+ {
+ lock (pools.SyncRoot)
+ {
+ string key = driver.Settings.GetConnectionString(true);
+ MySqlPool pool = (MySqlPool)pools[ key ];
+ if (pool == null)
+ throw new MySqlException("Pooling exception: Unable to find original pool for connection");
+ pool.ReleaseConnection( driver );
+ }
+ }
+ }
+}
Deleted: branches/1.0/mysqlclient/common/Resources.cs
===================================================================
--- branches/1.0/mysqlclient/common/Resources.cs 2006-08-30 20:07:45 UTC (rev 330)
+++ branches/1.0/mysqlclient/common/Resources.cs 2006-08-30 20:14:41 UTC (rev 331)
@@ -1,38 +0,0 @@
-// Copyright (C) 2004-2006 MySQL AB
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as published by
-// the Free Software Foundation
-//
-// There are special exceptions to the terms and conditions of the GPL
-// as it is applied to this software. View the full text of the
-// exception in file EXCEPTIONS in the directory of this software
-// distribution.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-using System;
-using System.Resources;
-
-namespace MySql.Data.Common
-{
- internal class Resources
- {
- private static ResourceManager rm = null;
-
- public static string GetString(string name)
- {
- if (rm == null)
- rm = new ResourceManager("MySql.Data.MySqlClient.MySqlClient.Strings",
- System.Reflection.Assembly.GetCallingAssembly());
- return rm.GetString (name);
- }
- }
-}
| Thread |
|---|
| • Connector/NET commit: r331 - in branches/1.0/mysqlclient: . common | rburnett | 30 Aug |