Dim i as integer
For i=0 to Ds.Tables("tables").rows().count-1
If Ds.Tables("tables").rows(i).item("字段")="" then '''查询条件
''条件成立
else
''条件不成立
End if
Next
' Set PrimaryKey
customerTable.Columns("id").Unique = true
customerTable.PrimaryKey = new DataColumn() { customerTable.Columns("id") }
' add ten rows
Dim id As Integer
For id = 1 To 10
customerTable.Rows.Add( _
new object() { id, string.Format("customer{0}", id) } )
Next id
customerTable.AcceptChanges()
' add another ten rows
For id = 11 To 20
customerTable.Rows.Add( _
new object() { id, string.Format("customer{0}", id) } )
Next id
Dim strExpr As String
Dim strSort As String
strExpr = "id > 5"
' Sort descending by CompanyName column.
strSort = "name DESC"
' Use the Select method to find all rows matching the filter.
Dim foundRows As DataRow() = _
customerTable.Select( strExpr, strSort, DataViewRowState.Added )
PrintRows( foundRows, "filtered rows")
foundRows = customerTable.Select()
PrintRows( foundRows, "all rows")
End Sub
Private Sub PrintRows( rows() As DataRow, label As String)
Console.WriteLine( "\n{0}", label )
If rows.Length <= 0 Then
Console.WriteLine( "no rows found" )
Exit Sub
End If
Dim r As DataRow
Dim c As DataColumn
For Each r In rows
For Each c In r.Table.Columns
Console.Write( "\t {0}", r(c) )
Next c
Console.WriteLine()
Next r
End Sub
[C#]
private static void GetRowsByFilter()
{