对Dataset 进行查询的几中方法。

1. 查询的数据用dataview 显示

 

  DataRow[] drStock = dsStockInfo.Tables[0].Select("");
    DataTable dtStock =dsStockInfo.Tables[0].Clone();
   //提取数据一行一列的添加到视图中在grdOrderDetail中显示
   for(int i=0; i<drStock.Length;i++)
   {
    DataRow drr= dtStock.NewRow();
    for(int j=0;j<dtStock.Columns.Count;j++)
    {
     drr[j] = drStock[i][j];
    }
    dtStock.Rows.Add(drr);
   }
   dvStock   =   new   DataView(dtStock);

 

 

2. 把数据集从一个导入到另一个

m_dataSetNew=dsSupplyInfo.Clone();

 m_dataSetNew.Tables[0].Clear();
    dsSupplyInfo.Tables[0].DefaultView.RowFilter = "Expr2="+PickLine+" and CLASSNAME= '" +ProductType +"' and CLIENTCODE= " +orderNo +" ";
    dsSupplyInfo.Tables[0].DefaultView.AllowNew = false;
    //提取数据一行一列的添加到视图中在grdOrderDetail中显示
    for(int i=0; i<dsSupplyInfo.Tables[0].DefaultView.Count;i++)
    {
     m_dataSetNew.Tables[0].ImportRow(dsSupplyInfo.Tables[0].DefaultView[i].Row);
    }
    
    this.hkdgSupply.DataSource   =   m_dataSetNew.Tables[0];

 

3. 过滤只是一个显示

   dsStockInfo.Tables[0].DefaultView.RowFilter = "PICKLINE="+PickLine+" and CLASSNAME= '" +ProductType +"' and ORDERID= " +orderNo +" ";
    dsStockInfo.Tables[0].DefaultView.AllowNew = false;
    //提取数据一行一列的添加到视图中在grdOrderDetail中显示
    this.hkdgStock.DataSource=dsStockInfo.Tables[0].DefaultView;

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值