/// <summary> /// Returns an ArrayList of the rows of the results of the /// given query. /// </summary> /// <param name="query">The SQL to execute</param> /// <returns>ArrayList of hashtables of row data</returns> public ArrayList GetAllHash(string query) { SQLiteResultSet results = this.Execute(query); ArrayList rows = new ArrayList(); // Loop through rows calling GetRowHash() while (results.IsMoreData) { rows.Add(results.GetRowHash()); } return(rows); }
/// <summary> /// Executes the supplied query and returns an SQLiteResultSet object /// </summary> /// <remarks> /// <p> /// If the database is busy (ie with another process/thread using it) then /// this method will call Thread.Sleep(), and then retry the query. Number of /// retries and retry delay are configurable using the appropriate properties.</p> /// <p>The result set object may be empty if there are no results, or if the /// query does not return results (eg. UPDATE, INSERT, DELETE etc)</p> /// </remarks> /// <param name="query">The SQL query to execute</param> /// <exception cref="SQLiteException"> /// Thrown if an error occurs or if the database is busy and the retries /// are exhausted. /// </exception> /// <returns>SQLiteResultSet of results</returns> public unsafe SQLiteResultSet Execute(string query) { SQLiteResultSet resultSet = new SQLiteResultSet(); this.Execute(query, (obj, columnNames, data) => { SQLiteResultSet result_set = obj as SQLiteResultSet; if (result_set.columnNames.Count == 0) { result_set.columnNames.AddRange(columnNames); } result_set.rowData.Add(new ArrayList(data)); return(0); }, resultSet); return(resultSet); }
/// <summary> /// Returns the first column of the first row of a queries result set /// </summary> /// <remarks> /// Useful for such queries as: SELECT COUNT(*) FROM myTable /// </remarks> /// <example> /// <code> /// db = new SQLite("testdb"); /// string strCount = db.GetOne("SELECT COUNT(*) FROM myTable"); /// int intCount = Int32.Parse(strCount); /// </code> /// </example> /// <param name="query">The query to execute</param> /// <returns>A string of the result</returns> public string GetOne(string query) { SQLiteResultSet resultSet = this.Execute(query); return(resultSet.GetField(0, 0)); }
/// <summary> /// Returns a hashtable row of resultset with given row index /// </summary> /// <param name="query">The query to perform</param> /// <param name="row">The row index to return</param> /// <returns>Hashtable of row data</returns> public Hashtable GetRowHash(string query, int row) { SQLiteResultSet resultSet = this.Execute(query); return(resultSet.GetRowHash(row)); }
/// <summary> /// Returns the specified row of a queries result set /// </summary> /// <remarks> /// Use this method to get an ArrayList of a particular row of a /// query. The row is a zero based index. /// </remarks> /// <param name="query">The query to execute</param> /// <param name="row">The row to retrieve</param> /// <returns>An ArrayList of the results</returns> public ArrayList GetRow(string query, int row) { SQLiteResultSet resultSet = this.Execute(query); return(resultSet.GetRow(row)); }
/// <summary> /// Returns the specified column of a queries result set /// </summary> /// <remarks> /// Use this method to get an ArrayList of a particular column of a /// query. The column is a zero based index. /// </remarks> /// <param name="query">The query to execute</param> /// <param name="column">The column to retrieve</param> /// <returns>An ArrayList of the results</returns> public ArrayList GetColumn(string query, int column) { SQLiteResultSet resultSet = this.Execute(query); return(resultSet.GetColumn(column)); }
/// <summary> /// Returns an ArrayList of the rows of the results of the /// given query. /// </summary> /// <param name="query">The SQL to execute</param> /// <returns>ArrayList of rows</returns> public ArrayList GetAll(string query) { SQLiteResultSet results = this.Execute(query); return(results.Rows); }