如何将数据集值转换为变量 [英] how to take DataSet Value into an variable

查看:78
本文介绍了如何将数据集值转换为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
谁能告诉我如何将数据集值"转换为变量?
谢谢

Hello there,
Can any one tell me how to take DataSet Value into an variable?
Thanks

推荐答案

您可以将数据集的特定单元格值设置为变量.像这样
You can set particular cell value of dataset into variable. like this
string name= Convert.ToString(ds.Tables[0].Rows[0]["name"]);


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 :

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. :)


这篇关于如何将数据集值转换为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆