我正在尝试(使用SQL和VB.Net)使用SELECT命令获取日期和字符串列表(表示电影名称),然后查看列表中的每个“日期”,一个另一个。就像'FOR EACH'循环一样。
我不完全确定如何做到这一点,但这是我到目前为止所做的:
Dim Con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;DataSource=ApplicationData.accdb;Persist Security Info=False;") Con.Open() 'Open the connection Dim Cmd As New OleDbCommand("SELECT fDateAdded, fName FROM Films", Con) Cmd.CommandType = CommandType.Text Dim Rdr As OleDbDataReader = Cmd.ExecuteReader() Dim schemaTable As DataTable = Rdr.GetSchemaTable() Dim row As DataRow Dim column As DataColumn For Each row In schemaTable.Rows For Each column In schemaTable.Columns ' WHAT TO DO HERE? Next Next
我如何实现目标?
答案 0 :(得分:1)
你的下一个循环应该是这样的......
For Each row As DataRow In dtDataTable.Rows
If row.Item("fDateAdded") = *your match criteria* Then
*Do something - you can utilies* row.Item("fName") *if you need*
End if
Next row
匹配标准当然可以是任何< < => > =或组合给你一个范围等。
希望有所帮助。