public static DataTable ExecuteSelectCommand(DbCommand command) { DataTable table; // The DataTable to be returned // Execute the command, making sure the connection gets closed in the // end try { // Open the data connection command.Connection.Open(); // Execute the command and save the results in a DataTable DbDataReader reader = command.ExecuteReader(); table = new DataTable(); table.Load(reader); // Close the reader reader.Close(); } catch (Exception ex) { utilities.LogError(ex); throw; } finally { // Close the connection command.Connection.Close(); } return table; }
pre
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)