标题:DataSet的问题
只看楼主
jljhwang
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2008-6-30
 问题点数:0 回复次数:2 
DataSet的问题
数据库在别处更新,这里使用DataSet显示,可显示的内容没有更新,该怎么做?谢谢
搜索更多相关主题的帖子: DataSet 
2009-11-04 07:31
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
得分:0 
DataSet重新载入啊

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2009-11-04 08:39
jljhwang
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2008-6-30
得分:0 
protected void ShowDataNews(int SelectIndex)
    {

        Label5.Text = (index+1).ToString();
            SqlConnection conn = new SqlConnection(@"Server=(local)\sqlexpress;uid=sa;pwd=1111;database=webdatabase");
            SqlDataAdapter da = new SqlDataAdapter(@"select * from news order by newsid desc", conn);
            SqlDataAdapter daKind = new SqlDataAdapter(@"select * from kind", conn);
            SqlDataAdapter daTeam = new SqlDataAdapter(@"select * from team", conn);
        if(ds.Tables["news"]==null)
        {
        
            conn.Open();
            da.Fill(ds, "news");
            daKind.Fill(ds, "kind");
            daTeam.Fill(ds, "team");
            conn.Close();
        }
        
            //da.Update(ds, "news");

        ds.AcceptChanges();
      try
      {
          TextBox8.Text = ds.Tables["news"].Rows[SelectIndex][1].ToString();
          TextBox9.Text = ds.Tables["news"].Rows[SelectIndex][2].ToString();
          DropDownList5.DataSource = ds.Tables["kind"];
          DropDownList5.DataTextField = "kind_name";
          DropDownList5.DataValueField = "kind_id";
          DropDownList5.DataBind();
          DropDownList5.SelectedValue = ds.Tables["news"].Rows[SelectIndex][4].ToString();


          DropDownList6.DataSource = ds.Tables["team"];
          DropDownList6.DataTextField = "teamname";
          DropDownList6.DataValueField = "teamid";
          DropDownList6.DataBind();
          DropDownList6.SelectedValue = ds.Tables["news"].Rows[SelectIndex][5].ToString();

          if (index > ds.Tables["news"].Rows.Count - 2)
          {
              index = ds.Tables["news"].Rows.Count - 1;

              Button12.Visible = false;
          }

          if (index == 0)
          {
              index = 0;
              Button11.Visible = false;
          }
      }
      catch (System.Exception ex)
      {
         
      }
        
        int dscount = ds.Tables.Count;
        Response.Write(dscount.ToString() + "//");

    }
这是绑定代码,用button执行,不显示啊。
2009-11-04 09:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-290945-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.538238 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved