I have a DataTable which contains 3 columns
id name val
1 a 2
2 b 3
3 c 4
4 d 12
5 e 14
there are five variables string a,string b,string c,string d,string e.I want to assign a value,from name column a value which is 2 to variable a,similary b value to variable b.I have done it this way
a = dt.Rows[0]["val"]
b = dt.Rows[1]["val"]
c = dt.Rows[2]["val"]
d = dt.Rows[3]["val"]
e = dt.Rows[4]["val"]
this is assigning values,but the way is going wrong.Please do let me know the other way i am stuck on this.
Regards,
Aniket Narvankar

Francis SusaimichaelPosted Jun 16, 2016, 1:23 AM
@Aniket,If you need anyother solution like yours then we can include using if..else statement instead of switch..case inside for loop. Wecan try with while..loop too.In my perspectiveI don't think, howthese options are considered as alternatives.
Since your ultimate result needs get thevalues from the each row and assign to the separate "string"variables. :)
Aniket NarvankarPosted Jun 16, 2016, 12:22 AM
Vinay SinghPosted Jun 15, 2016, 4:15 AM
Rajesh SahooPosted Jun 15, 2016, 3:36 AM
Francis SusaimichaelPosted Jun 15, 2016, 3:30 AM
Since you want to get thevalues from the each row and assign to the separate "string"variables, this is thepossibleway AFAIK. I think, you feel that the code is repeated multiple times. But this is how you need to achieve this one.
Aniket NarvankarPosted Jun 15, 2016, 3:07 AM
Vinay SinghPosted Jun 15, 2016, 2:57 AM
Rajesh SahooPosted Jun 15, 2016, 2:57 AM