Loading

DataTable.Select() 方法的简单用法

这个方法还是比较好用的,可以得到在datatable里你想要的符合条件的多个列 我的代码里用的是强类型dataset(项目里用的) 下面是代码片段,不完整,只是说明的用法
 If arrSyouhinCDList.Count > 0 Then
                    For i = 0 To arrSyouhinCDList.Count - 1
                        strSyouhinCD = arrSyouhinCDList(i).ToString
                        Dim rows() As DataRow
                        rows = dsM_syouhin_daihyou_kanren.m_syouhin_daihyou_kanren.Select("syouhin_cd='" & strSyouhinCD & "'")

                        For Each row As DataRow In rows
                            strDaihyouCD = row.Item("daihyou_cd").ToString
                            arrDaihyouCDList.Add(strDaihyouCD)
                        Next
                        arrAllDaihyouCD.Add(arrDaihyouCDList)
                        arrDaihyouCDList.Clear()
                    Next i
                End If


select方法里的参数叫"FilterExpression",写法就像拼SQL字符串一样
select方法的返回值是Datarow()(datarow集合,就是多个datarow) 再用for each方法取得想要的值就行了

Powered by ScribeFire.

posted @ 2007-08-20 10:12  码农加一  阅读(2524)  评论(0编辑  收藏  举报