private static FirebirdDBProvider NewProvider_Internal(string commandText, string connectionString, CommandType commandType)
        {
            FirebirdDBProvider provider = new FirebirdDBProvider();
            try
            {
                IDbTransaction transaction = null;
                if (GlobalTransaction.IsGlobalTransactionInProgress())
                {
                    transaction = GlobalTransaction.CurrentGlobalTransaction.GetDbTransaction(connectionString, provider);
                    provider.Connection = (FbConnection)transaction.Connection;
                }
                else
                {
                    provider.Connection = (FbConnection)provider.CreateConnection(connectionString);
                    provider.Connection.Open();

                    //Increment our counter for the number of open connections
                    FirebirdDBProvider.numberOfCurrentlyOpenConnections++;
                }

                provider.Command = provider.Connection.CreateCommand();
                provider.Command.CommandType = commandType;
                provider.Command.CommandText = commandText;

                if (transaction != null)
                {
                    provider.Command.Transaction = (FbTransaction)transaction;
                }
            }
            catch (Exception e)
            {
                throw (new Exception(e.Message));
            }
            return provider;
        }
        internal static FirebirdDBProvider NewDataSetProvider(string deleteStoredProcedureName,
                                                    string insertStoredProcedureName,
                                                    string selectStoredProcedureName,
                                                    string updateStoredProcedureName,
                                                    string connectionString,
                                                    bool withTransaction)
        {
            FirebirdDBProvider provider = new FirebirdDBProvider();

            try
            {

                IDbTransaction transaction = null;
                if (GlobalTransaction.IsGlobalTransactionInProgress())
                {
                    transaction = GlobalTransaction.CurrentGlobalTransaction.GetDbTransaction(connectionString, provider);
                    provider.Connection = (FbConnection)transaction.Connection;
                    withTransaction = true;
                }
                else
                {
                    provider.Connection = (FbConnection)provider.CreateConnection(connectionString);
                    provider.Connection.Open();

                    // Increment our counter for the number of open connections
                    FirebirdDBProvider.numberOfCurrentlyOpenConnections++;
                }

                FbCommand command = provider.Connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = selectStoredProcedureName;

                provider.DataAdapater = new FbDataAdapter(command);

                command = provider.Connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = deleteStoredProcedureName;
                provider.DataAdapater.DeleteCommand = command;

                command = provider.Connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = insertStoredProcedureName;
                provider.DataAdapater.InsertCommand = command;

                command = provider.Connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = updateStoredProcedureName;
                provider.DataAdapater.UpdateCommand = command;

                if (withTransaction)
                {
                    command.Transaction = (FbTransaction)transaction;// provider.fbTransaction = provider.Connection.BeginTransaction();
                    provider.DataAdapater.DeleteCommand.Transaction = command.Transaction;
                    provider.DataAdapater.InsertCommand.Transaction = command.Transaction;
                    provider.DataAdapater.UpdateCommand.Transaction = command.Transaction;
                    provider.DataAdapater.SelectCommand.Transaction = command.Transaction;
                }
            }

            catch (Exception e)
            {
                throw (new Exception(e.Message));
            }
            return provider;
        }