Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there,
Can any one tell me how to take DataSet Value into an variable?
Thanks
Posted
Comments
Ism Oss 10-Oct-15 20:38pm    
How to represent a form control ,e.g text box , As a record in mdb database table for updating or adding or deleting while using odbc in c++\clr application

1 solution

You can set particular cell value of dataset into variable. like this
C#
string name= Convert.ToString(ds.Tables[0].Rows[0]["name"]);
or
C#
string firstrowvalue = ds.Tables[0].Rows[0][0].ToString();

string secondrowvalue = ds.Tables[0].Rows[1][0].ToString();

string thirdrowvalue = ds.Tables[0].Rows[2][0].ToString();

using loop you can iterate values in the variable or if you are binding values into data binding control then also do the same :
C#
int value=0;
for(i=0;i<ds.tables.rows.count;i++)>
{
  int value=value + Convert.ToInt32(ds.Tables[0].Rows[0]["value"]);
}


Hope this will help you.
And don't forget to mark as answer if it helps. :)
 
Share this answer
 
v2
Comments
CRDave1988 10-Feb-12 1:12am    
5
Rajesh Anuhya 10-Feb-12 1:36am    
Well explained, have my +5
--RA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900