请问我怎么的不到数据集合中”系统环境“ 的第一个字段的值啊!晕死了,找了半天!大家帮帮我啊!TextBox2.Text = ds.Tables("系统环境").Columns(2).ToString 
这个得到的好象是段名啊! 
该怎么写啊? 得到它的值啊!例外,我要怎样才可以将绑定"系统环境"的某个字段绑定到TextBox2.Text属性啊?

解决方案 »

  1.   

    TextBox2.Text = ds.Tables("系统环境").Row[0][1].ToString;
      

  2.   

    ds.Tables("系统环境").Rows[1][2].ToString()用中文作为表名?
      

  3.   

    这样好像是不行的,你用Read一个一个的读到TextBox2里吧
      

  4.   

    您用的是Vb.Net还是C#啊,如果是C#,则为:
    TextBox2.Text = ds.Tables["系统环境"].Rows[0][0].ToString()
    C#里的第一个字段下标是从0起编的。如果为Vb.net,则为:
    TextBox2.Text = ds.Tables("系统环境").Rows(1)(1).ToString()
    我记得Vb.Net里的第一个字段下标是从1起编的。
      

  5.   

    Dim myConnection As New SqlConnection
            ' 建立一个数据适配器以便针对数据源执行 SELECT 语句来提取出要填入数据集的数据记录
            Dim myCommand As New SqlDataAdapter
            Dim ds As DataSet = New DataSet        myConnection.ConnectionString = "Data Source=localhost; Initial Catalog=publicselectedcourse; User ID=sa; Password="
            myCommand.SelectCommand = New SqlCommand
            myCommand.SelectCommand.CommandText = "SELECT LimitSecSum,StuEnTime,StuSecPECTime,TeaEnTime,TeaModStuFormTime,TeaModStuAchTime FROM SystemEviromentForm"
            myCommand.SelectCommand.Connection = myConnection
            myCommand.Fill(ds, "系统环境")
            TextBox1.Text = ds.Tables("系统环境").Row(0)(1).ToString;
            TextBox2.Text = ds.Tables("系统环境").Columns(2).ToString
            TextBox3.Text = ds.Tables("系统环境").Columns(3).ToString
            TextBox4.Text = ds.Tables("系统环境").Columns(4).ToString
            TextBox5.Text = ds.Tables("系统环境").Columns(5).ToString
    我的代码!按照 wxqq2001(就让我用一生等待)的方法. 它提示Row不是system.data.datatabale的成员的 语法错误!
      

  6.   

    PS:Vb.net没怎么用,是依照VB的经验改过来的,不能保证100%正确
      

  7.   

    TextBox2.Text = ds.Tables("系统环境").Rows(1)(1).ToString
    应该是绝对没错的,我刚才在VB。NET里验证了一下
      

  8.   

    lantianyuan(阳光少年) ,是哦!原来是Rows啊!知道了,谢谢!另外:我要怎样才可以将绑定"系统环境"的某个字段绑定到TextBox2.Text属性啊?
      

  9.   

    你不是已经给textbox2赋值了吗?还帮定啥呢?而且你的ds.Tables用中文干嘛,用数字或E文不行吗?