首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

dataset变换数组

2013-01-11 
dataset转换数组存储过程:dbo.Web_GetNoticeAll(@SchoolID int )ASSelect * from Tr_NewsInfo where Ne_Ty

dataset转换数组
存储过程:
dbo.Web_GetNoticeAll
(
@SchoolID int
 )
AS
Select * from Tr_NewsInfo where Ne_Type = '实训通知'and SchoolID = @SchoolID order by Ne_Date DESC  
RETURN


DAL层

DataSet Web_GetNoticeAll(int schoolid);


 public DataSet Web_GetNoticeAll(int schoolid)
        {
            //定义数据公共访问基类对象
            SQLHelper helper = new SQLHelper();

            //定义参数集
            SqlParameter[] parms = {
                                              new SqlParameter ("@SchoolID",SqlDbType.Int)
            };
            parms[0].Value = schoolid;

            //执行公共的数据访问类中的ExecuteDataSet
            DataSet ds = helper.ExecuteDataSet("Web_GetNoticeAll", parms);
            return ds;

        }


BLL层

  public DataSet Web_GetNoticeAll(int schoolid)
        {
            TStudentInterface inotice = TStudentFactory.Create();
            return inotice.Web_GetNoticeAll(schoolid);
        }


后台:        
      [WebMethod(Description = "查看实训通知列表")]
        public DataSet GetNoticeAll(int schoolid)
        {
            TStudentBLL NoticeA = new TStudentBLL();
            string Tschoolid;
            Tschoolid =Convert.ToString ( schoolid);
            DataSet ds = NoticeA.Web_GetNoticeAll(Convert.ToInt32(schoolid));
            return ds;
        }



返回的是dataset  老师让我们返回数组 怎么改(没学过数组,网上的一些方法都看不懂)

[解决办法]
 public DataSet 改为  public string[](字符串数组),函数中从数据集循环去数,然后写到数组
[解决办法]
数组追加
List<Int32> list = new List<Int32>();


for(Int32 i = 0;i < 10;i++)
  list.Add(i);

[解决办法]
object[][] str=null; 
for(int i = 0;i <ds.Tables[0].Rows.Count;i++) 

   for(int j=0;j < ds.Tables[0].Columns.Count;j++) 
   { 
       str[i][j] = ds.Tables[0].Rows[i][j].ToString(); 
   } 




[解决办法]
DataTable 直接转DataRow[]?
DataRow[] rows=dt.select("条件可以为空","排序可以忽略");

热点排行