I have a simple SQL query (using SqlCommand, SqlTransaction) in .NET 2.0 that returns a table of integer-string pairs (ID, Name). I want to get this data into a dictionary like
You can return it as a DataReader, and construct the dictionary using linq:
Dictionary dictionary;
using (SqlCommand command = new SqlCommand(queryString, connection))
using (SqlDataReader reader = command.ExecuteReader()) {
dictionary = reader.Cast()
.ToDictionary(row => (int)row["id"], row => (string)row["name"]);
}