获取今天的日期在ms访问时大于1天的最后一笔交易

时间:2015-05-08 16:34:03

标签: sql vb.net ms-access-2010

我有这段代码:

    cnn.Open()
        query = "SELECT LAST(AnnualPayments.DueDate), Members.FirstName, Members.LastName " & _
        "FROM AnnualPayments INNER JOIN Members ON AnnualPayments.MemID = Members.ID " & _
        "WHERE (((DateDiff('d', Now(), AnnualPayments.DueDate)) < 1)) " & _
        "GROUP BY  Members.FirstName, Members.LastName,  AnnualPayments.DueDate " & _
        "ORDER BY AnnualPayments.DueDate DESC"

        cmd = New OleDbCommand(query, cnn)

        Dim dt As New DataTable
        ds = New DataSet
        ds.Tables.Add(dt)
        da = New OleDbDataAdapter(cmd)
        da.Fill(dt)

        Dim newRow As DataRow

        For Each newRow In dt.Rows

            MainForm.lstView1.Items.Add(newRow.Item(0)) 
            MainForm.lstView1.Items(MainForm.lstView1.Items.Count - 1).SubItems.Add(newRow.Item(1)) 
            MainForm.lstView1.Items(MainForm.lstView1.Items.Count - 1).SubItems.Add(newRow.Item(2)) 
        Next

    Catch ex As Exception
        GetErrorMessage(ex)
    Finally
        CloseConnection()
    End Try

如果截止日期超过今天的1天,它应该只显示数据。你能纠正我的错误吗?感谢。

0 个答案:

没有答案