I was missing the obvious!! But I didn't notice it actually - just
"playing" with code really so glad to find the solution.

Thanks

A

On 16 Nov, 05:44, Cerebrus <[email protected]> wrote:
> Quite simple, so I'm sure you figured it out after you asked here.
> Nevertheless, the answer follows:
>
> There are two problems with your code sample:
> ~ The Add is a method, not a property so you cannot assign to it. The
> method call expects parameters, namely the key and value of the item
> to add to the Dictionary.
> ~ You seem to be (trying to) add column values but are actually adding
> the result of ToString() on each DataRow in the table. For instance,
> in the following table
>
> ---
> 1.1  1.2  1.3
> 2.1  2.2  2.3
> 3.1  3.2  3.3
> ---
>
> .. the code (if it worked) would add "System.Data.DataRow" three
> times. (or something like that... I haven't tried this.)
>
> What you would need to do is first identify the column which will
> serve as the Key and that which will be the value of each Dictionary
> item. Then use something like follows :
>
> ---
> foreach (DataRow dr in myData.Rows)
> {
>   myList.Add(dr["KeyColumn"], dr["ValueColumn"]);}
>
> ---
>
> HTH.

Reply via email to