protected override object CreateInstance(Type itemType)
		{
			object[] items = base.GetItems(null);

			int i = 1;
			while (true) 
			{
				bool found = false;
				foreach (object obj in items) 
				{
					MySqlParameter p = (MySqlParameter)obj;
					if (p.ParameterName.Equals( "parameter" + i )) 
					{
						found = true;
						break;
					}
				}
				if (! found) break;
				i ++;
			}

			MySqlParameter parm = new MySqlParameter("parameter"+i, MySqlDbType.VarChar);
			return parm;
		}
Exemple #2
0
		/// <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;
		}
Exemple #3
0
		private MySqlParameter CreateParameter(DataRow row, bool Original)
		{
			MySqlParameter p;
			if (Original)
				p = new MySqlParameter( "@Original_" + (string)row["ColumnName"], (MySqlDbType)row["ProviderType"],
					ParameterDirection.Input, (string)row["ColumnName"], DataRowVersion.Original, DBNull.Value );
			else
				p = new MySqlParameter( "@" + (string)row["ColumnName"], (MySqlDbType)row["ProviderType"],
					ParameterDirection.Input, (string)row["ColumnName"], DataRowVersion.Current, DBNull.Value );
			return p;
		}
Exemple #4
0
		object System.ICloneable.Clone() 
		{
			MySqlParameter clone = new MySqlParameter( paramName, dbType, direction,
				sourceColumn, sourceVersion, paramValue );
			return clone;
		}
		/// <summary>
		/// Adds the specified <see cref="MySqlParameter"/> object to the <see cref="MySqlParameterCollection"/>.
		/// </summary>
		/// <param name="value">The <see cref="MySqlParameter"/> to add to the collection.</param>
		/// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
		public MySqlParameter Add(MySqlParameter value)
		{
			if ( value.ParameterName == null ) throw new ArgumentException("parameter must be named");

			_parms.Add(value);
			return value;
		}