DataTable.Load Performance Slow, DataAdapter = Fast
I did a simple performance test using the new DataTable.Load(DataReader) method
The both of these queries return 70461 rows from SQLServer 2000 table.
Performance is as follows:
Using DataTable.Load() = 8.473 seconds
Using DataAdapter = 2.814 seconds
DataTable.Load() very slow compared to DataAdapter, why is this.
Maybe someone can spot a problem in my code:
// Using SqlDataAdapter.Fill() = 2.814 seconds (Much Faster) String connectionString = "data source=Danielle;initial catalog=ZIPInfo;integrated security=true"; String sqlQuery = "SELECT * FROM ZIPCODES";// WHERE StateCode = 'NV'"; DataTable dt = new DataTable("Test"); using (SqlConnection oSqlConnection = new SqlConnection(connectionString)) using (SqlCommand sqlCommand = new SqlCommand(sqlQuery, oSqlConnection)) using (SqlDataAdapter da = new SqlDataAdapter(sqlCommand)) |
// Using DataTable.Load() = 8.473 seconds (Much Slower) String connectionString = "data source=Danielle;initial catalog=ZIPInfo;integrated security=true"; String sqlQuery = "SELECT * FROM ZIPCODES";// WHERE StateCode = 'NV'"; DataTable dt = new DataTable("Test"); using (SqlConnection oSqlConnection = new SqlConnection(connectionString)) using (SqlCommand sqlCommand = new SqlCommand(sqlQuery, oSqlConnection)) using (SqlDataReader rdr = sqlCommand.ExecuteReader()) |

