/// <summary> /// read the data by executing the command object we pass on and then read all the data into a /// hash-table we return; first column is always the ID and second always the Name; the ID is /// used as the key and the Name as the value in the hash-table /// </summary> /// <param name="DbConnection">the database connection to use</param> /// <param name="DbCommand">the command object to use</param> /// <param name="ExceptionStringResourceName">the user-friendly exception; the resource string name we read</param> /// <returns>the hash-table with the ID/Name values; returned to the caller</returns> private static Hashtable ReadValuesIntoHashtable(IDbConnection DbConnection, IDbCommand DbCommand, string ExceptionStringResourceName, AddRecordInfo AddRecordInfoDelegate) { // create the empty hashtable Hashtable NameValues = new Hashtable(); try { IDataReader DataReader = DbCommand.ExecuteReader(); // now read all the information belonging to the user into a hash-table; the first column // contains always the ID and the second column the name; and we read it one-to-one into // the hashtable while (DataReader.Read()) { // if we a delegate has been passed along then call it to add the values to the // hash-table if (!(AddRecordInfoDelegate == null)) { AddRecordInfoDelegate(NameValues, DataReader); } // otherwise implement a standard way how values are added to the hash-table else { NameValues.Add(DataReader.GetString(0), DataReader.GetString(1)); } } } // if we run into any error reading the into, then re-throw a user-friendly exception catch (Exception e) { throw new DataLayerException(GetString(ExceptionStringResourceName)); } // the hash-table with the info return(NameValues); }
/// <summary> /// read the data by executing the command object we pass on and then read all the data into a /// hash-table we return; first column is always the ID and second always the Name; the ID is /// used as the key and the Name as the value in the hash-table /// </summary> /// <param name="DbConnection">the database connection to use</param> /// <param name="DbCommand">the command object to use</param> /// <param name="ExceptionStringResourceName">the user-friendly exception; the resource string name we read</param> /// <returns>the hash-table with the ID/Name values; returned to the caller</returns> private static Hashtable ReadValuesIntoHashtable(IDbConnection DbConnection, IDbCommand DbCommand,string ExceptionStringResourceName,AddRecordInfo AddRecordInfoDelegate) { // create the empty hashtable Hashtable NameValues = new Hashtable(); try { IDataReader DataReader = DbCommand.ExecuteReader(); // now read all the information belonging to the user into a hash-table; the first column // contains always the ID and the second column the name; and we read it one-to-one into // the hashtable while (DataReader.Read()) { // if we a delegate has been passed along then call it to add the values to the // hash-table if (!(AddRecordInfoDelegate == null)) AddRecordInfoDelegate(NameValues,DataReader); // otherwise implement a standard way how values are added to the hash-table else NameValues.Add(DataReader.GetString(0), DataReader.GetString(1)); } } // if we run into any error reading the into, then re-throw a user-friendly exception catch (Exception e) { throw new DataLayerException(GetString(ExceptionStringResourceName)); } // the hash-table with the info return NameValues; }