日期:2014-05-18  浏览次数:20422 次

高手
OleDbDataAdapter da = new OleDbDataAdapter("select top 5 * from info where pic=1 and nclassid=26 order by id desc", conn);
  DataTable dt = new DataTable(); 
  da.Fill(dt);
  for (int i = 0; i < dt.Rows.Count; i++)
  {
  strpics += dt.Rows[i]["DefaultPic"];
  if (i < 4) { strpics += "|"; }
  strlinks += "show.aspx?id=" + dt.Rows[i]["id"] + "|";  
  strtitles += dt.Rows[i]["title"] + "|";
  }
  conn.Close();

我想把 strlinks += "show.aspx?id=" + dt.Rows[i]["id"] + "|";// 这一句修改成两个索引strlinks += "show.aspx?id=" + dt.Rows[i]["id"] + "&"nid=" + dt.Rows[i]["nclassid"] + "|";但是运行时只显示id索引,却没有nid索引,为什么?怎么修改才对?谢谢


------解决方案--------------------
C# code

OleDbDataAdapter da = new OleDbDataAdapter("select top 5 * from info where pic=1 and nclassid=26 order by id desc", conn);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataTable dt = ds.Table[0].DefultView;  
        for (int i = 0; i < dt.Rows.Count; i++) 
        { 
            strpics += dt.Rows[i]["DefaultPic"]; 
            if (i < 4) { strpics += "|"; } 
            strlinks += "show.aspx?id=" + dt.Rows[i]["id"] + "&nid=" + dt.Rows[i]["nclassid"];
        } 
        conn.Close();

------解决方案--------------------
C# code

OleDbDataAdapter da = new OleDbDataAdapter("select top 5 * from info where pic=1 and nclassid=26 order by id desc", conn);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataTable dt = ds.Table[0].DefultView;  
        for (int i = 0; i < dt.Rows.Count; i++) 
        { 
            strpics += dt.Rows[i]["DefaultPic"]; 
            if (i < 4) { strpics += "|"; } 
            strlinks += "show.aspx?id=" + dt.Rows[i]["id"] + "&nid=" + dt.Rows[i]["nclassid"];
        } 
        conn.Close();