SQL Command Result to Dictionary C# .NET 2.0

Posted by Joel on Stack Overflow See other posts from Stack Overflow or by Joel
Published on 2010-03-29T15:31:35Z Indexed on 2010/03/29 15:33 UTC
Read the original article Hit count: 517

Filed under:
|
|
|

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 Dictionary.

I can get the result into a DataTable, but even iterating over it, I'm not sure how to do the typing and all that stuff. I feel like this must be a common problem but I haven't found any good solutions.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about sql

Related posts about .NET