Home All Groups Group Topic Archive Search About

Getting values out of the datatablereader

Author
10 Jan 2006 3:46 PM
kaushas
This should be a no brainer but I not sure what is going on. I must be
missing something  (VS2005, C#, ADO .Net 2.0)
Here are the steps

1. Created a DataTableReader from an existing dataset (used in the combox)
2. Got the ordinals for the cols
3. When trying to get the values out of the two cols, it seems to get same
value for both the cols, the ID value instead of the value from the second
col. 

the values for the single table are
1    A
2    B
3   C
4   D

valuemem = (string) dr.GetValue(ord2);      should get me the value of
A,B,C,D but I get the ID value 1,2,3,4 insted, not sure what am I missing.

Code is shown below:

DataTableReader dr = docsTypeDataSet.CreateDataReader();

                ord1 = dr.GetOrdinal("DocumentTypeCode");
                ord2 =dr.GetOrdinal("TypeName");


                while (dr.Read())
                {

                    if (dr[ord1].Equals(docComboBox.SelectedValue))
                    {

                        valuemem = (string) dr.GetValue(ord2);   //should
get value A,B,C,D instead I get 1,2,3,4 depending on the selected index value

                    }
                }


Thanks

Author
11 Jan 2006 9:19 PM
kaushas
Does anyone has any ideas on this issue? MS folks????

Show quote
"kaushas" wrote:

> This should be a no brainer but I not sure what is going on. I must be
> missing something  (VS2005, C#, ADO .Net 2.0)
> Here are the steps
>
> 1. Created a DataTableReader from an existing dataset (used in the combox)
> 2. Got the ordinals for the cols
> 3. When trying to get the values out of the two cols, it seems to get same
> value for both the cols, the ID value instead of the value from the second
> col. 
>
> the values for the single table are
> 1    A
> 2    B
> 3   C
> 4   D
>
> valuemem = (string) dr.GetValue(ord2);      should get me the value of
> A,B,C,D but I get the ID value 1,2,3,4 insted, not sure what am I missing.

> Code is shown below:
>
> DataTableReader dr = docsTypeDataSet.CreateDataReader();
>                
>                 ord1 = dr.GetOrdinal("DocumentTypeCode");
>                 ord2 =dr.GetOrdinal("TypeName");
>
>                
>                 while (dr.Read())
>                 {
>                    
>                     if (dr[ord1].Equals(docComboBox.SelectedValue))
>                     {
>
>                         valuemem = (string) dr.GetValue(ord2);   //should
> get value A,B,C,D instead I get 1,2,3,4 depending on the selected index value
>                
>                     }
>                 }
>
>
> Thanks
>

AddThis Social Bookmark Button