请问怎样从数据集里获取其中一个字段值啊???用什么代码 dataSet.Tables[0].Rows[i]["字段名"] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ds.Tables[0].Rows[行索引][列索引].ToString(); object objValue = ds.Tables["hehe"].Rows[行索引][列索引]; 就是DataRow的索引,object objValue = ds.Tables["hehe"].Rows[行索引][列索引];另外,如果楼主想到数据库取,如下:/// <summary> /// 获取单个值 /// </summary> /// <param name="strSql"></param> /// <returns></returns> public static object ExecuteScalar(string strSql) { object o = null; OleDbConnection myConn = new OleDbConnection(strConn); OleDbCommand myComm = new OleDbCommand(strSql,myConn); try { myConn.Open(); o = myComm.ExecuteScalar(); } catch(Exception e) { } finally { myConn.Close(); } return o; }当然你的sql语句类是与:select dd,rr form table2;返回的是第一个子段的值,上面是dd. ds.Tables[0].Rows[行索引][列索引].ToString();就是这个了 反正说的你们都说了bitsbird(一瓢.net) 就按照他的没有问题 C#打开文件夹 水晶报表使用 wpf如何做框架呢,比如像winform用menutrip菜单 窗口mdi模式,父窗口 组件注册gacutil时failure adding asembly to the cache 在DataGridViewComboBoxColumn中,向下的箭头能做到在用时显示,不用时隐藏吗? 求助!!!!!!!!!! 输入字符串的格式不正确 这个问题有点怪? 开发自定义控件的问题 那位高手来讲讲IFormatProvider啊? 数据库连接问题. 怎样才能在DataGrid中显示图象?
object objValue = ds.Tables["hehe"].Rows[行索引][列索引];
另外,如果楼主想到数据库取,如下:
/// <summary>
/// 获取单个值
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public static object ExecuteScalar(string strSql)
{
object o = null;
OleDbConnection myConn = new OleDbConnection(strConn);
OleDbCommand myComm = new OleDbCommand(strSql,myConn);
try
{
myConn.Open();
o = myComm.ExecuteScalar();
}
catch(Exception e)
{
}
finally
{
myConn.Close();
}
return o;
}当然你的sql语句类是与:select dd,rr form table2;
返回的是第一个子段的值,上面是dd.
就是这个了
bitsbird(一瓢.net)
就按照他的没有问题