Esempio n. 1
0
 public void ExecuteNonQuery(List <string> commandTexts)
 {
     using (AccessPoolManager.AccessPool pool = AccessPoolManager.Instance(this.connectionString))
     {
         using (OleDbTransaction transaction = pool.Connection.BeginTransaction())
         {
             using (OleDbCommand command = new OleDbCommand())
             {
                 try
                 {
                     command.Connection  = pool.Connection;
                     command.Transaction = transaction;
                     foreach (string str in commandTexts)
                     {
                         command.CommandText = str;
                         command.ExecuteNonQuery();
                     }
                     transaction.Commit();
                 }
                 catch
                 {
                     transaction.Rollback();
                     throw;
                 }
             }
         }
     }
 }
Esempio n. 2
0
 public OleDbDataReader ExecuteReader(string commandText, OleDbParameter[] pt)
 {
     AccessPoolManager.AccessPool pool = AccessPoolManager.Instance(this.connectionString);
     using (OleDbCommand command = new OleDbCommand(commandText, pool.Connection))
     {
         if (pt != null)
         {
             command.Parameters.AddRange(pt);
         }
         return(command.ExecuteReader(CommandBehavior.CloseConnection));
     }
 }
Esempio n. 3
0
 public void ExecuteNonQuery(string commandText, OleDbParameter[] pt)
 {
     using (AccessPoolManager.AccessPool pool = AccessPoolManager.Instance(this.connectionString))
     {
         using (OleDbCommand command = new OleDbCommand(commandText, pool.Connection))
         {
             if (pt != null)
             {
                 command.Parameters.AddRange(pt);
             }
             command.ExecuteNonQuery();
         }
     }
 }
Esempio n. 4
0
 public void Dispose()
 {
     if (AccessPoolManager.pools.ContainsKey(this.id) && (AccessPoolManager.pools[this.id] != null))
     {
         AccessPoolManager.AccessPool pool = AccessPoolManager.pools[this.id];
         pool.IsUsing = false;
         TimeSpan span = (TimeSpan)(DateTime.Now - pool.StartTime);
         if (span.TotalSeconds > AccessPoolManager.timeOut)
         {
             pool.Connection.Close();
             AccessPoolManager.pools.Remove(this.id);
         }
     }
 }
Esempio n. 5
0
        public DataTable ExecuteDataTable(string commandText, OleDbParameter[] pt)
        {
            DataTable dataTable = new DataTable();

            using (AccessPoolManager.AccessPool pool = AccessPoolManager.Instance(this.connectionString))
            {
                using (OleDbDataAdapter adapter = new OleDbDataAdapter(commandText, pool.Connection))
                {
                    if (pt != null)
                    {
                        adapter.SelectCommand.Parameters.AddRange(pt);
                    }
                    adapter.Fill(dataTable);
                }
            }
            return(dataTable);
        }
Esempio n. 6
0
        public object ExecuteScalar(string commandText, OleDbParameter[] pt)
        {
            object obj2;

            using (AccessPoolManager.AccessPool pool = AccessPoolManager.Instance(this.connectionString))
            {
                using (OleDbCommand command = new OleDbCommand(commandText, pool.Connection))
                {
                    if (pt != null)
                    {
                        command.Parameters.AddRange(pt);
                    }
                    obj2 = command.ExecuteScalar();
                }
            }
            return(obj2);
        }