Getting values out of the datatablereader

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top