/// <summary>
        /// Execute a TurboDBCommand (that returns a 1x1 resultset) against the specified TurboDBTransaction
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// e.g.:  
        ///  int orderCount = (int)ExecuteScalar(trans, CommandType.Text, "Select count(Order) from TableTransaction where ProdId=?", new TurboDBParameter("@prodid", 24));
        /// </remarks>
        /// <param name="transaction">A valid TurboDBTransaction</param>
        /// <param name="commandType">The CommandType (TableDirect, Text)</param>
        /// <param name="commandText">The T-SQL command</param>
        /// <param name="commandParameters">An array of TurboDBParamters used to execute the command</param>
        /// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
        public static object ExecuteScalar(TurboDBTransaction transaction, CommandType commandType, string commandText, params TurboDBParameter[] commandParameters)
        {
            if( transaction == null ) throw new ArgumentNullException( "transaction" );
            if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );

            // Create a command and prepare it for execution
            TurboDBCommand cmd = new TurboDBCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, (TurboDBConnection)transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);

            // Execute the command & return the results
            object retval = cmd.ExecuteScalar();

            // Detach the TurboDBParameters from the command object, so they can be used again
            cmd.Parameters.Clear();
            return retval;
        }
        /// <summary>
        /// Execute a TurboDBCommand (that returns a 1x1 resultset) against the specified TurboDBConnection 
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// e.g.:  
        ///  int orderCount = (int)ExecuteScalar(conn, CommandType.Text, "Select count(Order) from TableTransaction where ProdId=?", new TurboDBParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connection">A valid TurboDBConnection</param>
        /// <param name="commandType">The CommandType (TableDirect, Text)</param>
        /// <param name="commandText">The T-SQL command</param>
        /// <param name="commandParameters">An array of TurboDBParamters used to execute the command</param>
        /// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
        public static object ExecuteScalar(TurboDBConnection connection, CommandType commandType, string commandText, params TurboDBParameter[] commandParameters)
        {
            if( connection == null ) throw new ArgumentNullException( "connection" );

            // Create a command and prepare it for execution
            TurboDBCommand cmd = new TurboDBCommand();

            bool mustCloseConnection = false;
            PrepareCommand(cmd, connection, (TurboDBTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection );

            // Execute the command & return the results
            object retval = cmd.ExecuteScalar();

            // Detach the TurboDBParameters from the command object, so they can be used again
            cmd.Parameters.Clear();

            if( mustCloseConnection )
                connection.Close();

            return retval;
        }