Ejemplo n.º 1
0
        /// <summary>
        /// checks if the result for this query is already cached.
        /// If not, the result is retrieved from the database.
        /// The result is added to the cache, and the result is returned
        /// as a ArrayList from the cache.
        /// The ArrayList consists of the strings
        /// of the first column of the first table in the dataset.
        ///
        /// </summary>
        /// <returns>void</returns>
        public ArrayList GetStringList(DB.TDataBase db, String sql)
        {
            ArrayList ReturnValue = new ArrayList();
            DataSet   ds          = GetDataSet(db, sql);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                ReturnValue.Add(Convert.ToString(row[0]));
            }

            return(ReturnValue);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// checks if the result for this query is already cached.
        /// If not, the result is retrieved from the database.
        /// The result is added to the cache, and the result is returned
        /// as a DataSet from the cache.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="sql"></param>
        /// <param name="ATable">can already have some prepared columns; optional parameter, can be null
        /// </param>
        /// <returns>void</returns>
        public DataSet GetDataSet(DB.TDataBase db, String sql, DataTable ATable)
        {
            DB.TDBTransaction ReadTransaction;
            Boolean           NewTransaction = false;
            DataSet           newDataSet;

            int counter = 0;

            foreach (string sqlstr in storedSQLQuery)
            {
                if (sqlstr == sql)
                {
                    // create a clone of the result, so that the returned datasets
                    // can be treated separately
                    return(((DataSet)storedDataSet[counter]).Copy());
                }

                counter++;
            }

            try
            {
                ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                                                                                    TEnforceIsolationLevel.eilMinimum,
                                                                                    out NewTransaction);

                if (ATable == null)
                {
                    newDataSet = db.Select(sql, "Cache", ReadTransaction);
                }
                else
                {
                    newDataSet = new DataSet();
                    newDataSet.Tables.Add(ATable);
                    ATable.TableName = "Cache";
                    db.Select(newDataSet, sql, "Cache", ReadTransaction);
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                }
            }
            storedDataSet.Add(newDataSet);
            storedSQLQuery.Add(sql);

            // return a copy, so that changes to the dataset don't affect the stored copy.
            return(newDataSet.Copy());
        }
Ejemplo n.º 3
0
 /// <summary>
 /// checks if the result for this query is already cached.
 /// If not, the result is retrieved from the database.
 /// The result is added to the cache, and the result is returned
 /// as a DataTable from the cache.
 /// </summary>
 /// <param name="db"></param>
 /// <param name="sql"></param>
 /// <param name="ATable">can already have some prepared columns; optional parameter, can be nil
 /// </param>
 /// <returns>void</returns>
 public DataTable GetDataTable(DB.TDataBase db, String sql, DataTable ATable)
 {
     return(GetDataSet(db, sql, ATable).Tables["Cache"]);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// checks if the result for this query is already cached.
 /// If not, the result is retrieved from the database.
 /// The result is added to the cache, and the result is returned
 /// as a DataTable from the cache.
 /// </summary>
 /// <param name="db"></param>
 /// <param name="sql"></param>
 /// <returns></returns>
 public DataTable GetDataTable(DB.TDataBase db, String sql)
 {
     return(GetDataTable(db, sql, null));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// checks if the result for this query is already cached.
 /// If not, the result is retrieved from the database.
 /// The result is added to the cache, and the result is returned
 /// as a DataSet from the cache.
 /// </summary>
 /// <param name="db"></param>
 /// <param name="sql"></param>
 /// <returns></returns>
 public DataSet GetDataSet(DB.TDataBase db, String sql)
 {
     return(GetDataSet(db, sql, null));
 }