c# 使用sqlServer 数据

来源:百度知道 编辑:UC知道 时间:2024/07/02 08:27:35
使用c#中的sqldatasource从sqlserver2000中查询出一条记录的一个字段后,我想把该字段值显示在label上,请问如何实现?
补充一下,我使用sqldatasource设置了selectCommand=" select Value from table where name = '1' ",
然后我怎样才能将该sqldatasource查询出的字段显示给label呢?

label1.Text=row["fields"].ToString();
其中label1为label的ID号,row为当前记录,fields为该字段的字段名

有2种的到数据的
datareader 和dataset
labal.text=datareader['列名'];或者
labal.text=dataset.tables['表名或表序号'].rows[行号][列号]