/// <summary> /// Retrieve the data table to the associated query. /// </summary> /// <param name="query">SQL command (query).</param> /// <param name="path">Full path to the database file.</param> /// <returns>A dataset of type System.Data.DataTable.</returns> public static DataTable GetDataTable(string query, string path, string tableName = null) { //debug output the query string System.Diagnostics.Debug.WriteLine(query); //Build the data table; DataTable fetchedTable = null; //Configure the data access service; DataAccess da = new DataAccess(); CollectionMethod method = new CollectionMethod(da.GetTable); //Execute the query; IAsyncResult result = method.BeginInvoke(query, Query.OpenConnection(path), null, null); //Fetch the result of the query from the data service; fetchedTable = method.EndInvoke(result) as DataTable; //Return the table; if (fetchedTable != null) { return(fetchedTable); } else { return(new DataTable()); } }
/// <summary> /// Retrieve the data table to the associated query. /// </summary> /// <param name="query">SQL command (query).</param> /// <param name="path">Full path to the database file.</param> /// <returns>A dataset of type System.Data.DataTable.</returns> public static DataTable GetDataTable(string query, string path, string tableName = null) { //debug output the query string System.Diagnostics.Debug.WriteLine(query); //Build the data table; DataTable fetchedTable = null; //Configure the data access service; DataAccess da = new DataAccess(); CollectionMethod method = new CollectionMethod(da.GetTable); //Execute the query; IAsyncResult result = method.BeginInvoke(query, Query.OpenConnection(path), null, null); //Fetch the result of the query from the data service; fetchedTable = method.EndInvoke(result) as DataTable; //Return the table; if (fetchedTable != null) return fetchedTable; else return new DataTable(); }